connection reset by peer
James R Drinkwater
jd at csd4.milw.wisc.edu
Sun Feb 5 18:40:55 AEST 1989
I've been playing around with BSD4.3 sockets and ran into a problem.
The server accepts a connection under the internet address family and
and forks. The child duplicates the socket returned from accept as
stdin and stdout. It then loops, reading a line from stdin and
passing the line to system(). When a blank line, '\n', or read()
returns 0,stdout is shutdown with no furthersends or receives allowed.
The client loops, reading a line from the keyboard and writes to its
socket. The data from the server is read asynchronously when SIGIO
is received. If the client's stdin (keyboard) is closed, the socket is
shutdown with no further sends allowed.
My problem is this: I send the server the line "cat filename". A
majority of filename is printed and then the client hangs. After hitting
two <RET>'s, the output resumes and usually finishes. Once finished,
I send another line to the server. When SIGIO is received, my read()
in the io handler returns the error "connection reset by peer".
The <RET>'s I sent were interpreted by the server as blank lines
so the socket is shutdown. I assume this is what the error means.
Why does the output hang?
More information about the Comp.unix.questions
mailing list