Return to BSD News archive
Newsgroups: comp.unix.bsd.freebsd.misc,comp.os.linux.development.apps Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.bhp.com.au!mel.dit.csiro.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.cis.okstate.edu!news.ksu.ksu.edu!news.physics.uiowa.edu!math.ohio-state.edu!uwm.edu!newsfeed.internetmci.com!EU.net!sun4nl!rnzll3!sys3.pe1chl!rob From: rob@pe1chl.ampr.org (Rob Janssen) Subject: Re: Checking for a closed socket connection Reply-To: pe1chl@wab-tis.rabobank.nl Organization: PE1CHL Message-ID: <DLzIH5.AAy@pe1chl.ampr.org> References: <NEWTNews.822505959.29723.jalvarez@sundev.uno.com> <4e7l8n$50f@charm.il.ft.hse.nl> <4effu2$ega@phoenix.ea4els.ampr.org> <d6wag372qps.fsf@pentagram.troll.no> Date: Tue, 30 Jan 1996 08:05:28 GMT Lines: 36 Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:13385 comp.os.linux.development.apps:11756 In <d6wag372qps.fsf@pentagram.troll.no> Arnt Gulbrandsen <agulbra@troll.no> writes: >> is it acceptable therefore to read 0 bytes, or write 0 bytes? >The TCP protocol allows packets with 0 bytes payload, but I would not >recommend using it at the application layer - you're staking too much >on the kernel implementation. TCP cannot send 0-byte packets. Actually, a user cannot send TCP packets at all! TCP is a stream-based protocol. The user submits data, and TCP is free to packetize it in packets of any size it likes, and send it on the connection. You cannot be sure the packet size will have any relation to the size of your write(). The only thing you can be quite sure of, is that a 0-size write will not result in a 0-size packet. This is because such a packet is merely an ACK, and would not be acked by the other side. There is little point in sending it.... (note that a "keepalive" may look like a 0-size packet, but in fact it contains an already-acked sequence number, and thus it is not really the same thing. the other side sees it as an old duplicate, and ACKs it). UDP, being packet oriented, can send 0-size packets. However, this is tricky just as well, as some broken implementations may not deliver the received 0-byte packet to the user. (There was a bug in this in Linux as well, but it was fixed after I hit it... the RFC 868 "Time Protocol" specifies that you can send a 0-size UDP packet to the server, and get the current time in a UDP reply) Rob -- +------------------------------------+--------------------------------------+ | Rob Janssen rob@knoware.nl | BBS: +31-302870036 (2300-0730 local) | | AMPRnet: rob@pe1chl.ampr.org | AX.25 BBS: PE1CHL@PI8WNO.#UTR.NLD.EU | +------------------------------------+--------------------------------------+