netdev
[Top] [All Lists]

Strangeness when write()-ing zero-length datagrams

To: netdev@xxxxxxxxxxx
Subject: Strangeness when write()-ing zero-length datagrams
From: "Michael T Kerrisk" <mtk-lists@xxxxxxx>
Date: Mon, 9 Aug 2004 16:38:13 +0200 (MEST)
Sender: netdev-bounce@xxxxxxxxxxx
Godday,

On Linux 2.4.26 and 2.6.7, if we connect a datagram socket and 
then use write() to send 0 bytes, a datagram is NOT generated 
(this happens in both the Unix and Internet domains).  
Datagrams are generated in this case for send() and sendto() 
though.  

As far as I can work out, this occurs because of the 
following code in net/socket.c::sock_write/sock_aio_write():

    if(size==0)        /* Match SYS5 behaviour */
        return 0;

Is the Linux behaviour intended?  It seems counterintuitive, 
and it does not match what I see on other systems:

Solaris 8 does not behave like Linux in this case -? a zero 
length datagram is sent and read by the receiver (tested for 
Internet and Unix domain sockets).

Tru64 5.1 is the same as Solaris 8 (tested for Internet and 
Unix domain sockets)

HP-UX 11 is the same as Solaris 8 (tested for Internet and 
Unix domain sockets)

FreeBSD 4.9 and 5.1 are the same as Solaris 8 (tested for 
Internet and Unix domain sockets)

Cheers,

Michael

-- 
Michael Kerrisk
mtk-lists@xxxxxxx

NEU: WLAN-Router für 0,- EUR* - auch für DSL-Wechsler!
GMX DSL = supergünstig & kabellos http://www.gmx.net/de/go/dsl


<Prev in Thread] Current Thread [Next in Thread>