Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!rex!uflorida!gatech!purdue!mentor.cc.purdue.edu!dls From: dls@mentor.cc.purdue.edu (David L Stevens) Newsgroups: comp.protocols.tcp-ip Subject: Re: Questions on TCP shutdown and RFC-793 Message-ID: <2527@mentor.cc.purdue.edu> Date: 10 Dec 90 20:29:43 GMT References: <36540017@hpindwa.cup.hp.com> <2452@mentor.cc.purdue.edu> <1990Dec10.131116.19393@jarvis.csri.toronto.edu> Organization: PUCC UNIX Group Lines: 36 In article <1990Dec10.131116.19393@jarvis.csri.toronto.edu>, thomson@hub.toronto.edu (Brian Thomson) writes: > > I think the original question was about the TCP shutdown procedure, not the > BSD shutdown() system call, but this answer caught my attention because it > seems to contradict everything I thought I knew about the BSD routine. > My understanding is as follows: > shutdown(s, 0) - flushes data queued for receive, and shrinks > my receive window to zero. Succeeding reads will > fail. > shutdown(s, 1) - data already queued will be delivered, followed > by a FIN. Succeeding writes will fail. > shutdown(s, 2) - equivalent to { shutdown(s, 0); shutdown(s, 1); } > ... > > And, to top it off, my manual pages (Sun) say nothing about loss of > buffered data pending. Sorry, I had forgotten where I saw it. It isn't in the man page, and I originally came across it in the code, but I knew there was a documentation reference as well. The "IPC Primer" (section 2.6) says: "....Applying shutdown to a socket causes any data queued to be immediately discarded." Also, from the "Advanced 4.3BSD IPC Tutorial" (PS1:8-8): "Once a socket is no longer of interest, it may be discarded by applying close to the descriptor, close(s); If data is associated with a socket which promises reliable delivery (e.g., a stream socket) when a close takes place, the system will continue to attempt to transfer the data. However, after a fairly long period of time, if the data is still undelivered, it will be discarded. Should a user have no use for a any pending data, it may perform a shutdown on the socket prior to closing it." -- +-DLS (dls@mentor.cc.purdue.edu)