[M3devel] the so_linger inconsistency between Posix and Windows

Jay K jay.krell at cornell.edu
Fri Sep 18 07:19:25 CEST 2009


I've been reading up on SO_LINGER.
Search the web..

 


There are two or three options, depending on how you view it.

 


onoff=0
time=ignored

 

 

onoff=1
time=non-zero

 


onoff=1
time=0
You could view this as an example of the previous.


 

The behavior is governed by additional bits.
  - does the socket of buffered unset data?
  - is the socket blocking?


 

Some options result in the socket being "immediately"
closed and unsent buffered data not being sent,

and I think possibly the other side getting an error.

 


Some options have close return immediately but
send the buffered data in the "background".
This I believe is the default.

 


Some options have close block waiting for send to finish.
This has pluses/minuses.
The minus is -- what timeout to use?
A plus and minus is, I believe, there is an opportunity for
close to timeout and fail, letting the caller know that
there was a failure to deliver data.
It is good to know about failure, though you'd want to
know if the code was ready to somehow handle the failure.

 


onoff=0 seems "best".
onoff=1, time=0 seems "bad".
onoff=1, time="large" seems "ok", depending on how large.

 


I think onoff=0 is the default.
I will verify that with some getsockopt runs.

 


If it is the default, I think we should just remove the setsockopt(so_linger) code.

 


One might also imagine that 1 second is not a short time, so even the Windows
code isn't far off from the Posix code. The only big change would be
setting 1,0 or removing setting of 1,0.

 


What I wish we had but don't know if we have, is some major Modula-3
user of sockets on both Posix and Windows, so that the change can be
tested.

 


I think there is a basic problem in networking code, of unreliability
and inconsistent timing. You don't know how long to wait for something to occur,
when to give up waiting and deciding it failed.

 


 - Jay





 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090918/66ee4dd4/attachment-0001.html>


More information about the M3devel mailing list