473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

array tofile fromfile tosocket? fromsocket?

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?

Oct 3 '06 #1
2 1392
On Tue, 03 Oct 2006 10:29:00 -0700, "SpreadTooThin" <bj********@gmail.com>
let this slip:
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 ?

--
Thomas Jollans alias free-zombie
Oct 3 '06 #2

Thomas Jollans wrote:
On Tue, 03 Oct 2006 10:29:00 -0700, "SpreadTooThin" <bj********@gmail.com>
let this slip:
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 ?
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?

--
Thomas Jollans alias free-zombie
Oct 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: BadOmen | last post by:
I have made an array in a function in a Class now I need to get to that Array from an other function in an other Class, How do I do that? The Array has no fixed size as it is dependent on how...
2
by: MangoMan | last post by:
Hi there, Currently i am having a problem with python's array class. I am reading 3 arrays from a file (self.buffer32, self.buffer16, self.buffer8 from self.fs) : # ... self.Allocated32 =...
8
by: Paul in Toronto | last post by:
Got this assignment in my VB .NET class. The program's basically a picture viewer that lets you add your pictures to an array so you can cycle through them once the file's been opened. So you...
8
by: dan.winsor | last post by:
Hi all, I'm trying to write through SOAPpy in python to a Java implemented API. The API for the method I want to use is as follows: boolean added = SoapService.addAttachmentsToIssue(token,...
1
by: KraftDiner | last post by:
Can pythons array.tofile method be used for a TCP/IP Socket? ie can the socket be a file object?
7
by: SpreadTooThin | last post by:
I have some code... import array a = array.array('d') f = open('file.raw') a.fromfile(f, 10) now I need to convert them into floats (32 bit...) what do i do?
1
by: charles.hebert | last post by:
Hi, I want to write an 2d array in an ascii file using numpy. There's the - tofile / fromfile - function but it doesn't work with nd array. Thanks, CH.
0
by: Kanis | last post by:
Hi, I 'd to output an array to a file, however the "tofile" function can only work for <type numpy.ndarray> but not <type array>. So how can I change the <type array> to <type numpy.ndarray>? ...
3
by: Sean Davis | last post by:
I have a set of numpy arrays which I would like to save to a gzip file. Here is an example without gzip: b=numpy.ones(1000000,dtype=numpy.uint8) a=numpy.zeros(1000000,dtype=numpy.uint8) fd =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.