sockets question/broken pipe

sockets question/broken pipe

Post by Barry M. Cacer » Wed, 09 Jul 1997 04:00:00



i've written a simple client and server using BSD sockets for the TCP/IP
protocol and i'm having one problem that i can't figure out.  i seem to be
able to trap most errors and exit gracefully, but if my server crashes and
my client attempts a call to send() i have a problem.  i would think if
send() failed it would return a negative number, but instead it exits and
outputs "Broken pipe".  is there a way i can detect that the server has
gone away and exit gracefully.  fyi: i'm using IRIX 5.3 on an Indy Workstation.

thanks in advance for any help.  please respond by email at

-Barry M. Caceres

 
 
 

sockets question/broken pipe

Post by Kurt J. Lanz » Thu, 10 Jul 1997 04:00:00



> i've written a simple client and server using BSD sockets for the TCP/IP
> protocol and i'm having one problem that i can't figure out.  i seem to be
> able to trap most errors and exit gracefully, but if my server crashes and
> my client attempts a call to send() i have a problem.  i would think if
> send() failed it would return a negative number, but instead it exits and
> outputs "Broken pipe".  is there a way i can detect that the server has
> gone away and exit gracefully.  fyi: i'm using IRIX 5.3 on an Indy Workstation.

I believe the "Broken pipe" is a signal which you can arrange for
your client to catch. See signal() and other functions. Hope this helps.
--
Kurt J. Lanza


 
 
 

1. Socket broken pipe error

Hi, in a typical echo server program, I used two buffers, namely
char received[BUFSIZ] and char replied[BUFSIZ],
to read from and write to a stream socket respectively. Everything was
fine until I closed the socket gracefully in the client program. The
server caught this "broken pipe" error message due to a negative read()
from the closed socket.
There shouldn't be problem with the client as it worked well with another
echo server problem.

Then I commented out the statement
"memset(replied, 0, sizeof(replied))"
which used to appear before each write to the socket in that problematic
server program. This seems to rectify the situation as read() returns
0 in the server as expected whenever I quit the client and the error
message vanishes.

Later I found that the "bzero(replied, sizeof(replied))" also caused
similar "broken pipe" message to the server.

It seems quite strange to me that upon the closure of a socket by the
client, a mere memset()/bzero() caused the server reading a socket to
return a negative value instead of 0.

Has anyone come across similar similar situation? I couldn't find any
special mention about memset() and bzero() in this regard.

Cheers
Sunny Suen

2. Help for a 15 year old!

3. What does socket error "broken pipe" mean?

4. tcl/tk

5. net: eof!(write) socket 5 (Broken pipe,32)

6. Installing New Libraries

7. C++ sockets on unix, problems with broken pipe

8. Over 64MB Memory????

9. 'broken pipe' with sockets

10. Socket operations failing with "Broken Pipe"

11. error with apache on RH - (32)Broken pipe: accept: (client socket)

12. Question on knowing when a pipe connection breaks

13. TCP/IP broken socket question