[Chicago] Passing structure

Daniel Griffin dgriff1 at gmail.com
Thu Feb 25 23:14:34 CET 2010


It is a pretty open ended question. Does the C program essentially do:

char * source = (char*)recv(12); // or whatever the size of the struct

or does it use some sort of formatting? If its sending structs then you can
probably use the python struct module and you might have to worry about
endian-ness and structure packing.

Dan


On Thu, Feb 25, 2010 at 4:06 PM, Ed Marshall <esm at logic.net> wrote:

> On Wed, Feb 24, 2010 at 4:20 AM, Goudar, Girish <
> Girish.Goudar at goodrich.com> wrote:
>
>>  I want to pass a structure (which contains int, float, char etc) from a
>> client program written in Python to a server program written in C (Operating
>> system is DEOS). But the “socket.send” command in Python supports only
>> String or Readonly buffer. I want to pass a structure. Could you please help
>> me on this?
>>
> You might consider serializing your data structure as JSON or YAML and
> passing it that way:
>
> http://docs.python.org/library/json.html
> http://pyyaml.org/
>
> For something a littlle more Python-specific, pickle is also available:
>
> http://docs.python.org/library/pickle.html
>
> Perhaps that will give you a few ideas? :)
>
> --
> Ed Marshall <esm at logic.net>
> Felix qui potuit rerum cognoscere causas.
> http://esm.logic.net/
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20100225/3d0546e1/attachment.html>


More information about the Chicago mailing list