473,320 Members | 2,073 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,320 software developers and data experts.

serializing data structures

Hi,

I am trying to figure out the traps/issues about sending data structures
through a TCP/IP socket under the following circumstances:

1) there could be a different O/S on both side of the socket
2) there could be a difference CPU architecure on both side of the
socket
3) there could be a different major release of python (ex 2.3 and 2.4)
on both side of the socket.
I once wrote something in C to do that, but since python usually has a
solution for me ....
Any clue ?

Regards,
Philippe

--
***************************
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***************************

Jul 18 '05 #1
3 1555
Philippe C. Martin wrote:
I once wrote something in C to do that, but since python usually has a
solution for me ....


If you use arbitrary data structures, you could use pickle or xmlrpclib
to marshal the data. If you know the data is restricted to a few
well-known data types, you could use XDR (Demo/rpc/xdr.py) or CORBA
(e.g. through fnorb.sf.net) to come up with a wire format.

Otherwise, if you want to define your own proprietary data format,
you can probably use the struct module to generate messages according
to this format.

However, in any case, you need to define the wire format. Once you made
a choice, Python can help implement it - but Python cannot chose a wire
format for you (although pickle comes really close, as does Dopy -
http://www.mindhog.net/~mmuller/projects/dopy/)

Regards,
Martin
Jul 18 '05 #2
Thanks a lot.

Regards,

Philippe


On Tue, 01 Feb 2005 00:20:01 +0100, Martin v. Löwis wrote:
Philippe C. Martin wrote:
I once wrote something in C to do that, but since python usually has a
solution for me ....


If you use arbitrary data structures, you could use pickle or xmlrpclib
to marshal the data. If you know the data is restricted to a few
well-known data types, you could use XDR (Demo/rpc/xdr.py) or CORBA
(e.g. through fnorb.sf.net) to come up with a wire format.

Otherwise, if you want to define your own proprietary data format,
you can probably use the struct module to generate messages according
to this format.

However, in any case, you need to define the wire format. Once you made
a choice, Python can help implement it - but Python cannot chose a wire
format for you (although pickle comes really close, as does Dopy -
http://www.mindhog.net/~mmuller/projects/dopy/)

Regards,
Martin


Jul 18 '05 #3
"Philippe C. Martin" <ph*************@sbcglobal.net> writes:
I am trying to figure out the traps/issues about sending data structures
through a TCP/IP socket under the following circumstances:

1) there could be a different O/S on both side of the socket
2) there could be a difference CPU architecure on both side of the
socket
3) there could be a different major release of python (ex 2.3 and 2.4)
on both side of the socket.

I once wrote something in C to do that, but since python usually has a
solution for me ....


What do you mean by data structures? If they're limited to basic
objects like strings and ints, try xdrlib. If you want longs, class
instances, etc., there's really no good way in the Python stdlib that
doesn't create security vulnerabilities if the source of data isn't
trusted. See SF bugs 471893 and 467384 for some discussion.
Jul 18 '05 #4

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

Similar topics

10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
12
by: Cagdas Ozgenc | last post by:
Greetings, When directly serializing C++ structures to a file with the standard library functions giving the address of the data and length of structure using the sizeof operator, do I risk...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.