array tofile fromfile tosocket? fromsocket?

S

SpreadTooThin

Hi I am using arrays in an application.
They have been working very well for me as I have been using them for
reading and writing data to and from files whose endianisms can be big
or little endian.
However now I need handle data that can be transferred over a socket.

I would rather not have to go in and change every occurance of tofile
and fromfile to a function but realize that is what I may have to do.
I was under the impression that a file and socket were interchangable
(like a file descriptor). Does anyone have an idea that might help me
minimize the impact on my code?
 
T

Thomas Jollans

I was under the impression that a file and socket were interchangable
(like a file descriptor). Does anyone have an idea that might help me
minimize the impact on my code?

are you looking for sockets' makefile method ?
 
S

SpreadTooThin

Thomas said:
are you looking for sockets' makefile method ?
Yes.. but also I'm thinking about a new python class based on array...
like (psuedo code)

class myArray(array):
def todevice(self, device):
if device is a file:
self.tofile
else
writesocket(data)
def fromdevice(self, device):

Is this advisable?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top