how to transfer integer on socket?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Apr 20 23:09:41 EDT 2007


En Fri, 20 Apr 2007 23:48:58 -0300, Frank Potter <could.net at gmail.com>  
escribió:

> Is there any easy way to transfer 4 bit integer on socket?

Extend it to 8 bits (1 byte) and use a single character (string of length  
1)

> I want to send like this:
>
> a=5
> send_integer(socket_s,a)

socket_s.send(chr(a))

> and receive like this:
> a=receive_integer(socket_s)

a = ord(socket_s.recv(1))

-- 
Gabriel Genellina




More information about the Python-list mailing list