Reading socket binary data?

Peter Hansen peter at engcorp.com
Thu Feb 27 21:23:38 EST 2003


Michael Simpson wrote:
> 
> In C:
> struct FOO
> {
> short a;
> char b;
> long c;
> }
> 
> In Python, I get
> 
> data = socket.recv(1024)
> 
> How to I translate data to a struct FOO type or a series of objects that
> represent those fields?

Read the docs on the "struct" standard module...

-Peter




More information about the Python-list mailing list