Error when executing the library reference echo server example

Jean-Paul Calderone exarkun at divmod.com
Mon Dec 10 11:14:22 EST 2007


On Mon, 10 Dec 2007 06:38:57 -0800 (PST), diego.martin.a at gmail.com wrote:
> [snip]
>
>I tried it in Linux and it worked fine so I've been trying different
>things as the code seems to be correct.
>Finally, I've found that if both server and client are run from IDLE,
>the thing crashes with the mentioned error. But if the server is run
>within a shell and the client within IDLE (or another shell) it works
>perfectly. Therefore I suppose the problem is in IDLE (or in my actual
>IDLE version) and not in the code.

It's certainly true that it may work better in some environments, and
it is definitely true that many programs/libraries don't work as expected
when run from IDLE.

However, that doesn't mean that the example is correct.  Keep in mind
that handling error conditions is an important part of writing correct
programs.  You can't rely on everything always going right all the time.
Even if you stick with the socket module, you should make sure to handle
exceptions from socket calls and always check the return value of the
send method.

Jean-Paul



More information about the Python-list mailing list