ntohl/htonl socket transfer between c and python

Eivind B. Nilssen Eivind.Bergh.Nilssen at dnv.com
Tue Jun 25 02:41:40 EDT 2002


Hi,

I have a bit of a problem I cant seem to solve. I am new at
programming python,
and my task is to make a client in python for fetching data from a
remote server written in c.

The buffer sendt to me from the server is generated as follows:

*(int*)&bfr[bix] = htonl(*(int*)&f); #where f is a float value

The buffer received in my python program is a lot of strange asciis
I am not able to cast this buffer to an int or a long and this again
makes
me unable to apply the ntohl command.

Does anybody have an idea how to extract the data from this buffer?
Do I have to write this part in C?

Thanks a lot in advance.



More information about the Python-list mailing list