Sockets

Dan dan at dontspammecauseidontlikit.com
Thu Apr 7 22:34:43 EDT 2005




I'm using the socket module and have run into a problem.

I want to send binary data over the connection.  With C, this is easy:

write(sock_fd, data, length);

But it appears that the Python socket module has no method to send
binary data, it only sends strings.  So there's no argument to tell it
the length, it stops when it gets the end of string character (null).

The only way I can see around it is to encode the data, but this is
really just an inelegant hack.

Any suggestions?  Python is still new to me and I can't say that I've
mastered all its nuances.

Dan




More information about the Python-list mailing list