*BSD News Article 69148


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!asstdc.scgt.oz.au!nsw.news.telstra.net!act.news.telstra.net!imci3!newsfeed.internetmci.com!swrinde!cs.utexas.edu!ennfs.eas.asu.edu!noao!rstevens
From: rstevens@noao.edu (W. Richard Stevens)
Newsgroups: comp.unix.bsd.misc,comp.unix.sys5.r4,comp.unix.programmer
Subject: Re: TCP socket close() behavior (Was: Imcomplete Documents and Images from httpd)
Date: 22 May 1996 20:44:21 GMT
Organization: National Optical Astronomy Observatories, Tucson, AZ, USA
Lines: 33
Message-ID: <4nvub5$1j9@noao.edu>
References: <31a1f624@yoda.omnicron.com> <4ntd43$mn1@noao.edu> <4nvlrk$6kl@microl4.microlise.UUCP>
NNTP-Posting-Host: gemini.tuc.noao.edu
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.misc:1092 comp.unix.sys5.r4:11007 comp.unix.programmer:37701

> > Posix.1g, Draft 6.3 states "A normal disconnect initiated by closing a
> > TCP socket with the SO_LINGER option disabled or with a linger time other
> > than zero shall not cause data to be discarded" (p. 278).  That's pretty
> > explicit, and I maintain is the "existing practice".
> > 
> >        Rich Stevens
>
> So what does happen if you set a linger time other than 0 and close the
> socket, and the linger time is reached? I know many implementations
> ignore the actual time specified, is that conforming? If the time is
> *not* ignored, and is reached, what precisely is supposed to happen?

First, Posix explicitly states that the linger time is in seconds, so
the implementation should not ingore the time value.

Here's all they say: "If the SO_LINGER option is enabled with a time
other than zero, the close operation shall block until buffered data
and the FIN are acknowledged or until the linger time has expired; however,
the protocol shall continue to attempt delivery of any buffered data and FIN
after the close operation returns until any data and FIN are acknowledged
or the implementation times out."

They don't way what close() should return (which seems like an omission),
but BSD implementations return an error of EWOULDBLOCK if the linger time
expires.

> [where does one get hold of Posix drafts?]

The IEEE make this very hard, and since they earn significant revenue
from the selling of standards, they don't make them available to anyone
on the net.  Sigh.

	Rich Stevens