type converion in python

Winnie Poon wpoon at generalhydrogen.com
Wed May 28 16:34:19 EDT 2003


Hi,

 

I'm writing a socket server in python and I'm having some trouble
converting the data received.

 

Another socket client, which is written in C, sends data to a particular
ipaddress and port number and my job is to parse the data received.  Now
the problem is, the data sent from the client is an array of uint2. If
the server is written also in C/C++, then I can cast the char* to uint2
* and i would be able to obtain the data. 

 

char buf[MAXRECV+1];

uint2 * in_ptr = 0;

 

Msglen = recv(sock, buf, MAXRECV, 0)

 

in_ptr = (uint2*) (&buf[0]);

 

Now with python, I have trouble doing similar thing.  Anybody has done
this before? Any help is very much appreciated.  Thanks!

 

winnie

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030528/bc169576/attachment.html>


More information about the Python-list mailing list