sending binary data over sockets

Simon Forman rogue_pedro at yahoo.com
Mon Jul 3 21:51:36 EDT 2006


Grant Edwards wrote:
> On 2006-07-03, thorley at gmail.com <thorley at gmail.com> wrote:
>
> > My problem now, is that I need to send certain binary data over a
> > socket. That is, I want to make some bytes, and stuff them in a TCP
> > packet, send them down the pipe, and then listen for a response.
...
> > In my understaing the above just sends the string '\x01\x02\x03\x04',
> > not raw binary data.
>
> The string '\x01\x02\x03\x04' consists of four octets having
> the values 0x01, 0x02, 0x03, 0x04.
>
> Are those not the four octets you wanted to send?
> 
> -- 
> Grant Edwards

i.e.
>>> len('\x01\x02\x03\x04')
4




More information about the Python-list mailing list