Nico Williams wrote:
> On Fri, May 6, 2011 at 3:24 PM, James Carlson <carls...@workingcode.com> 
> wrote:
>> Kacheong Poon wrote:
>>> On 05/ 7/11 12:35 AM, Nico Williams wrote:
>>>
>>>> What would the alternative be?  That the socket lingers forever?
>>>
>>> The current Solaris behavior is that the TCP connection
>>> continues to do a graceful shutdown.  It is like a normal
>>> close() without setting the linger option.  I want to know
>>> if it is something we can change without breaking backward
>>> compatibility.  If the current behavior is actually the
>>> wrong behavior, it is just a bug we fix.
>> I'd be surprised to see TCP RST when l_linger is > 0.  That's not how
>> BSD operates.
> 
> I'd looked at one of the Stevens books, specifically the
> implementation of soclose(), but it seems I misread it.
> 
> Re-reading the documentation posted here, I agree, the socket must
> continue to shutdown gracefully.  (An application might then reset the
> linger option so that the socket is reset... it might be nice to have
> a simple API by which to request "linger upto N seconds, then give up
> and reset the connection".)

I think that already exists.  To get that behavior:

  - set l_onoff to 1 and l_linger to 0
  - do shutdown(fd,1) to send FIN
  - set a timer for N seconds
  - read(fd) to wait for EOF or timer
  - close(fd) or just exit

If the timer goes off and the connection is still open, then closing
with l_linger set to 0 will cause RST.  If the connection has already
closed gracefully, then the close(2) call just closes the socket without
RST.

-- 
James Carlson         42.703N 71.076W         <carls...@workingcode.com>
_______________________________________________
networking-discuss mailing list
networking-discuss@opensolaris.org

Reply via email to