Error when executing the library reference echo server example

diego.martin.a at gmail.com diego.martin.a at gmail.com
Mon Dec 10 09:38:57 EST 2007


On Dec 10, 1:48 pm, Jean-Paul Calderone <exar... at divmod.com> wrote:
> On Mon, 10 Dec 2007 04:16:03 -0800 (PST), diego.marti... at gmail.com wrote:
> >Hi. Python newbie speaking,
>
> >I've copy/pasted the example of the echo server that comes in the IDLE
> >documentation ("Python Library Reference" section 17.2.3) to see how
> >the sockets work. The only change I've made is in the host address
> >which I've set to 'localhost' in the client. You can see the complete
> >code below the message.
>
> >When I run it I get the following error:
> >     Traceback (most recent call last):
> >          File "C:\Python25\eclient.py", line 11, in <module>
> >          data = s.recv(1024)
> >     error: (10053, 'Software caused connection abort')
>
> >Is the example wrong? In this case, Where can I find a working
> >example? Have I messed up the example putting 'localhost'? (don't
> >think so, because I tried with '127.0.0.1' and I got the same error).
> >And the big one, Why I get the error and how can I avoid it in future
> >applications?
>
> >Lot of thanks in advance!!
>
> You're seeing the expected behavior.  The example doesn't take care to
> handle any error conditions.  It has other bugs as well, such as not
> checking the return value of socket.send().
>
> Here's a different echo example:
>
>  http://twistedmatrix.com/projects/core/documentation/examples/#auto0
>
> Jean-Paul

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.
Thanks for your answers Chris and Jean-Paul.



More information about the Python-list mailing list