how to send an int over a socket

Paul Rubin http
Fri Feb 4 21:30:31 EST 2005


Tom Brown <brown at esteem.com> writes:
> However, in my actual program I will not know the length of testmessage in 
> advance. So how do I convert msglen into a suitable format for the send 
> method?

    >>> str(123)
    '123'

You might also look at 

   http://cr.yp.to/proto/netstrings.txt

which describes some issues you should pay attention to, and suggests
a standardized format.



More information about the Python-list mailing list