*BSD News Article 60949


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!yarrina.connect.com.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.uoknor.edu!news.nodak.edu!netnews1.nwnet.net!news.u.washington.edu!uw-beaver!uhog.mit.edu!news.kei.com!nntp.coast.net!news00.sunet.se!sunic!news99.sunet.se!nntp-trd.UNINETT.no!due.unit.no!usenet
From: Arnt Gulbrandsen <agulbra@troll.no>
Newsgroups: comp.unix.bsd.freebsd.misc,comp.os.linux.development.apps
Subject: Re: Checking for a closed socket connection
Date: 31 Jan 1996 17:56:24 +0100
Organization: Troll Tech AS, fax +47 22646949
Lines: 40
Message-ID: <d6wohrkfglj.fsf@pentagram.troll.no>
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> <DLzIH5.AAy@pe1chl.ampr.org>
NNTP-Posting-Host: pentagram.troll.no
X-Newsreader: Gnus v5.0.8
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:13437 comp.os.linux.development.apps:11806

rob@pe1chl.ampr.org (Rob Janssen)
> In <d6wag372qps.fsf@pentagram.troll.no> Arnt Gulbrandsen <agulbra@troll.no> wr
ites:
>
> >> 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!

True.  And yet the TCP protocol allows the sending TCP stack to send a
packet with 0 bytes payload (without payload, if you wish).  The
crucial difference is that the user cannot send TCP packets at all.

It's possible for a user program to ask, but not to force the TCP
stack to send off a packet.  Before anyone says "that's wrong":
Consider what happens if the TCP stack obliges, the packet sent is
lost, and the client sends more data before the TCP stack resends.

There is a major difference between the TCP protocol and the various
implementations of it, and between the TCP stack and the TCP-using
client program.

> 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().

Quite.

As I said, even if inspection shows it to "work" on one particular TCP
stack it probably won't work on many others.

(I know I do it myself, but I really hate it when people followup to a
posting of mine without, apparently, reading it through.)

--Arnt