From owner-freebsd-current Wed Dec 25 07:38:35 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id HAA14583 for current-outgoing; Wed, 25 Dec 1996 07:38:35 -0800 (PST) Received: from scrooge.ee.swin.oz.au (scrooge.ee.swin.oz.au [136.186.4.20]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id HAA14578 for ; Wed, 25 Dec 1996 07:38:32 -0800 (PST) Received: (from dtc@localhost) by scrooge.ee.swin.oz.au (8.6.9/8.6.9) id CAA19656 for current@FreeBSD.org; Thu, 26 Dec 1996 02:40:32 +1100 From: Douglas Thomas Crosher Message-Id: <199612251540.CAA19656@scrooge.ee.swin.oz.au> Subject: Invalid Argument error writing to closed socket. To: current@FreeBSD.org Date: Thu, 26 Dec 1996 02:40:32 +1100 (EST) X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk I've been tracking a problem which occcurs when writing to a TCP socket for which the remote end has closed the connection - a write returns an Invalid Argument error, however I suspect that it should signal SIGPIPE. The relevant parts of a ktrace are included below. If anyone has any ideas I'd be grateful for some help. This is for a http server which persistent connections. Trouble occurs because the server thinks the connection is still live - I'm currently using getpeername to check. Is there a better more reliable way to determine if the connection is still live? Running FreeBSD-current 24/12/96. Regards Douglas Crosher -=-=-=- >From a ktrace log: At this point file descriptor 6 is a TCP socket, and the other end has closed the connection. A read returns 0 bytes i.e. EOF. 198 lisp CALL read(0x6,0x803b000,0x1000) 198 lisp GIO fd 6 read 0 bytes "" 198 lisp RET read 0 getpeername is not aware the connection is closed yet. 198 lisp CALL getpeername(0x6,0xefbfd8b0,0xefbfd8ac) 198 lisp RET getpeername 0 The next write returns an Invalid Argument error. However I'm confident that all the arguments are valid. Since the remote connection has closed the connection I expected a SIGPIPE error. 198 lisp CALL write(0x6,0x8040000,0x8d) 198 lisp RET write -1 errno 22 Invalid argument <<<<<<< The next write does give a SIGPIPE: 198 lisp CALL write(0x6,0x8040000,0x14) 198 lisp PSIG SIGPIPE caught handler=0x5564 mask=0x0 code=0x0 198 lisp RET write -1 errno 32 Broken pipe -=-=-=-=-