sending a byte on a socket

Andrew Bennetts andrew-pythonlist at puzzling.org
Wed Aug 27 09:18:06 CEST 2003


On Wed, Aug 27, 2003 at 02:02:14AM -0500, Pettersen, Bjorn S wrote:
> > From: Daniel Timothy Bentley [mailto:dbentley at stanford.edu] 
> > 
> > Slamming my head against what should be an easy problem:
> > 
> > How do I send a byte across an open, connected socket?
> > 
[...]
> 
> A one character string is a byte...
> 
>   byteString = chr(byte)

Calculating and sending single bytes at a time is probably unnecessarily
painful, though.  It wouldn't surprise me if the original poster finds that
the struct module makes their life much easier:
    http://www.python.org/doc/lib/module-struct.html

-Andrew.






More information about the Python-list mailing list