W3C home > Mailing lists > Public > www-lib@w3.org > January to March 1996

Re: How to handle Broken Pipe

From: Henrik Frystyk Nielsen <frystyk@w3.org>
Date: Mon, 26 Feb 1996 10:43:00 -0500
Message-Id: <9602261543.AA14734@www20>
To: Vu Nguyen <vu@isdnsys.com>
Cc: "'www-lib@w3.org'" <www-lib@w3.org>
Vu Nguyen writes:
> While testing my server which is based on the Mini Server, I ran into =
> this problem:  If I issue a request for a document from the browser and, =
> then hit the 'Stop' button while the document being transferred then I =
> have a broken pipe.  This occurs in HTWriter_write (HTStream * me, CONST =
> char * buf, int len)
> 
> below is the line which adds the error into the request's error list
> 
> HTRequest_addSystemError(request,  ERR_FATAL, socerrno, NO, "NETWRITE");
> 
> which generates:
> 
> Error Add... number:  44        Severity: 1     Parameter: `NETWRITE: =
> Broken pipe'      Where: `NETWRITE'
> 
> Why didn't SetSignal() do what it supposed to do?

On client side, the SetSignal() is only required on Solaris and some other 
SVR4-like systems which has a broken TCP stack. The problem occurs as soon as 
you try to use non-blocking sockets. If you have a non-blocking socket and try 
to connect to a valid host but on a non-supported port number, for example 
7777 where nothing is waiting, then you get SIG_PIPE back and your application 
dies. On many BSD-like TCP stacks you get "Invalid argument" which is also an 
error. The right response is of course "Connection refused" which both manage 
to handle if you use blocking sockets.

In the case above, however, the situation's different as you're the server and 
the client has pre-maturely closed the connection. In this case you will get a 
"broken pipe" in which case you will have to handle the signel. As you can 
see, this is already done by SetSignal() as the server doesn't die but just 
registers the broken pipe and continues.


-- 

Henrik Frystyk Nielsen, <frystyk@w3.org>
World-Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA
Received on Monday, 26 February 1996 10:43:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:26 GMT