socket send help

James Mills prologic at shortcircuit.net.au
Mon Jan 5 20:02:43 EST 2009


On Wed, Dec 24, 2008 at 3:59 PM, greywine at gmail.com <greywine at gmail.com> wrote:
(snip)

> If I run testserver.py via the cmd prompt in Windows XP and then the
> testclient.py program, I get the following error:
>
> Traceback (most recent call last):
>  File "C:\Python30\testclient.py", line 12, in <module>
>    s.send('Hello world')               # send the data
> TypeError: send() argument 1 must be string or buffer, not str
>
> This happens in 2.6 or 3.0 and with different example client & server
> programs from the web.  What am I missing?

I'm sorry I should have answered sooner :)
Python 3.x (and probably 2.6+) required that you use
bytes to send your data through sockets rather than
strings. This was part of the revamp for better unicode
support irrc.

cheers
James



More information about the Python-list mailing list