*BSD News Article 69118


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.mel.connect.com.au!news.mel.aone.net.au!imci4!newsfeed.internetmci.com!howland.reston.ans.net!newsjunkie.ans.net!newsfeeds.ans.net!n3ott.istar!istar.net!n1van.istar!news.vancouver.istar.net!news-w.ans.net!newsfeeds.ans.net!news.chips.ibm.com!mdnews.btv.ibm.com!news.rchland.ibm.com!usenet
From: hofer@vnet.ibm.com (Kent Hofer)
Newsgroups: comp.unix.bsd.misc,comp.unix.sys5.r4
Subject: Re: TCP socket close() behavior (Was: Imcomplete Documents and Images from httpd)
Date: 22 May 1996 13:23:44 GMT
Organization: IBM Rochester MN
Lines: 85
Message-ID: <4nv4h0$l8g@news.rchland.ibm.com>
References: <4m7r3m$9qt@nntpb.cb.att.com> <31979d8d@yoda.omnicron.com> <319900f5.21380062@news.meganet.nl> <319a205f@yoda.omnicron.com> <319b6555@yoda.omnicron.com> <4nkuav$q54@noao.edu> <31a1f624@yoda.omnicron.com>
Reply-To: hofer@vnet.ibm.com (Kent Hofer)
NNTP-Posting-Host: janeway.rchland.ibm.com
X-Newsreader: IBM NewsReader/2 v1.2.5
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.misc:1090 comp.unix.sys5.r4:11006

In <31a1f624@yoda.omnicron.com>, ford@omnicron.com (Mike "Ford" Ditto) writes:
>I am moving this thread to comp.unix.bsd.misc and comp.unix.sys5.r4
>since it has come down to a question of sockets semantics.
>
>I submit for discussion the question of whether the kernel must attempt
>to deliver pending sent data when a close() is performed on a connected
>TCP socket without the SO_LINGER option enabled.

stuff deleted...]

>The documentation for the SO_LINGER socket option (in both BSD and SVR4)
>is ambiguous, but not inconsistent with the above description.

AGREED, but what's new. There are quite a few cases in the sockets
BSD man pages where errno values are not listed that actually can 
get returned, or where errnos are returned but for reasons
other than documented, or even where errnos are documented
to be returned given specific error condition, but a simple
test of that condition proves that the wrong errno is documented.
I've come to regard the BSD man pages for sockets as something 
of a primer on how stuff works, with enough to get a simple 
program going, but definitely not a "specification" of the 
sockets API.  (I have no opinion of SVR4 man pages, being
less than familiar with them...)

>Therefore, I interpret that to strictly comply with the documented
>interface, it is necessary to enable SO_LINGER before closing a socket
>if you want to guarantee that the kernel will attempt to deliver all
>previously written data.
>
[following from Richard Stevens in the original post]
>> Are you saying these SVR4 stacks discarded the data in the send buffer
>> when close() was called and the LINGER option was not set?  If so, I say
>> the stacks are broken.
[back to Mr Ditto]
>
>SVR4.0 and at least some versions of SVR4.2/Unixware do not attempt to
>deliver unsent data in the case of a non-lingering close.
>
>I recieved some additional information from peter@haywire.DIALix.COM
>(Peter Wemm).  He says that the BSD implementation has in fact attempted
>to deliver the unsent data as far back as the net/1 code, and that the
>BSD Design & Implementation book is simply out of date.
>
>But it's not clear to me that the SVR4 behavior is actually "wrong" just
>because it matches the 4.3BSD spec (man pages) and not the net/1
>behavior.
>
>Is there any more authoritative documentation for this aspect of sockets
>semantics?  Is the httpd software "wrong" to omit the SO_LINGER option?
>
>					-=] Ford [=-
>

Sockets is a DEFACTO standard because most everybody started with
the BSD code base.  There is NO RFC to describe the behavior, and no
"spec".  I think that deviating from BSD implementation must be 
evaluated based on what it will do to portability of the application. 
In this specific instance, given such a base concept as "when to try
to deliver data", IMHO any stack that does not try to deliver data on
a close() with default values for SO_LINGER is broken.  This is
the way it "has always been".  Given that, various groups have
tried to write a sockets specification.  I'm sorry that I don't
have any URLs or ftp sites offhand to find the following, but...
You can try looking at the POSIX 1003.12 draft, or at the
"1170 specification" from X/Open.  (They renamed it to something
else and I can't remember the name anymore.  It was originally
"1170" because it had over 1170 UNIX type APIs "spec'd" in it).
I've read the documentation on both several years ago, and 
I recall the 1170 one being pretty much the standard man 
pages, with some additional streams errno's thrown in, 
probably from the SVR4 you mentioned, which I guess 
to be streams implementations and not BSD 
implementations?  The posix spec was only a preliminary
draft at the time (no idea if it progressed farther since
then) and it had little detail at the time...

BTW, you proposed the correct _practical_ solution of 
using the SO_LINGER option, if it is now working
on all platforms, even the ones that aren't quite
"BSDish" enough... :-)  I would never have thought to try
that, given my expectations of BSD compatibility.

Kent Hofer  hofer@vnet.ibm.com
(My views have nothing to do with IBM... standard disclaimer)