[M3devel] Posix/Win32 linger options inverted?

Olaf Wagner wagner at elegosoft.com
Mon Aug 31 13:20:56 CEST 2009


On Solaris I find

/*
  * Structure used for manipulating linger option.
  */
struct  linger {
         int     l_onoff;                /* option on/off */
         int     l_linger;               /* linger time */
};

so {1, 1} would make the socket linger for at most 1 second after
close, while {0, 0} would close the socket immediately and throw
away any data not sent yet.

The default linger time on Solaris seems to be 120 seconds btw.
I cannot really say why this difference is present, I can only guess
that one of them is a workaround for a bug.

Perhaps the intention was indeed to allow 1 second until data is sent,
but this didn't work on Windows?

Does anybody here know more?

Olaf

Quoting Jay K <jay.krell at cornell.edu>:

>
> ?
>
>
>
>> From: jay.krell at cornell.edu
>> To: m3devel at elegosoft.com
>> Date: Sun, 23 Aug 2009 06:26:34 +0000
>> Subject: [M3devel] Posix/Win32 linger options inverted?
>>
>>
>> http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-comm/tcp/src/POSIX/TCP.m3?rev=1.7;content-type=text%2Fplain
>>
>> vs.
>>
>> http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-comm/tcp/src/WIN32/TCP.m3?rev=1.3;content-type=text%2Fplain
>>
>>
>> search for linger:
>>
>> PROCEDURE InitFD(fd: CARDINAL) =
>> (* We assume that the runtime ignores SIGPIPE signals *)
>> VAR
>> one: int := 1;
>> linger := Usocket.struct_linger{1, 1};
>>
>> vs.
>>
>> PROCEDURE InitSock(sock: WinSock.SOCKET) =
>> (* We assume that the runtime ignores SIGPIPE signals *)
>> VAR
>> one : BOOL := 1;
>> linger := WinSock.struct_linger{0, 0};
>>
>>
>> Surely they can't both be correct.
>> Which is correct? The Posix one?
>>
>>
>> - Jay
>
>



-- 
Olaf Wagner -- elego Software Solutions GmbH
                Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23 45 86 96  mobile: +49 177 2345 869  fax: +49 30 23 45 86 95
    http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194




More information about the M3devel mailing list