Hi,

I have what seems to be a simple problem. But I can not for the life of me 
find a way to send an integer over a socket. The send method will only accept 
strings. Here is what I am trying to do:

testmessage = 'test message'
msglen = len(testmessage)
sock.send(msglen)
sock.send(testmessage)

Now, I know I can do this:

testmessage = 'test message'
sock.send('\xC') # send hard coded length of testmessage in hex in string
sock.send(testmessage)

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?

Thanks,
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to