socket client server... simple example... not working...
fakeaddress at nowhere.org
Fri Oct 6 08:02:48 CEST 2006
> Jean-Paul many thanks for this and your effort.
> but why is it every time I try to do something with 'stock' python I
> need another package?
Twisted has it's fan, but you don't "need" it. Your code had a few
specific problems, and fixing them has little or nothing to do with
> By the time I've finished my project there are like 5 3rd party add-ons
> to be installed.
> I know I'm a python newbie... but I'm far from a developer newbie and
> that can be a recipe for
> disaster. The stock socket should work and I think I've missed an
> obvious bug in the code other
> than checking the return status.
Obviously you wanted to recv() on your 'clientsocket' not your
'seversocket'. You can use sendall() to send all the given data;
it will raise an exception if it fails so there's no return code to
check. Since TCP is a stream protocol and does not have any concept
of message boundaries, you'll need to delimit messages within your
protocol, and call recv() until you have an entire message.
More information about the Python-list