socket: connection reset by server before client gets response

ahlongxp ahlongxp at gmail.com
Sun Jul 8 04:20:38 EDT 2007


> So, umm, what exactly are you trying to accomplish?

> It looks like what is happening is the server only accepts 99 bytes.  It
> then does the send and the close.
yes.  What I want is that, server sends response to client and closes
connection when it feels recieving enough information, and make sure
at the same time ,client will definitely get the response from server.

> The client wants to send 120 bytes, 10 bytes at a time.  By the time is
> does the 12th send the server has already finished, closing its socket
> and exiting.  So when the client attempts send #12 the socket is already
> closed.  Thus the error.
>

> I'm not sure why you are getting the 'connection reset' instead of
> 'broken pipe'.  Probably different OS.  (I'm using Mac OS X 10.4.10.)
>
as I saied before,  running results will varies. And most of the time
they are working quite well. But that's not enough.
> Anyway, I changed your code slightly, wrapping the send in a try/except
> block like this:
>      try:
>          s.send('0123456789')
>      except socket.error ,e:
>          print "Socket Error:", e
>          break
>
> Now here are my results for the client:
> time 0
> time 1
> time 2
> time 3
> time 4
> time 5
> time 6
> time 7
> time 8
> time 9
> time 10
> time 11
> error: (32, 'Broken pipe')
> Received 'OK'

This really helped.
Now I know the client will still get the response even under
'Connection reset by peer' or 'Broken pipe'.


> The way you had it the program crashed before it could do the receive.
>
> Frank
Frank, thanks a lot.

--
ahlongxp

Software College,Northeastern University,China
ahlongxp at gmail.com
http://www.herofit.cn




More information about the Python-list mailing list