Kacheong Poon wrote:
I want to gather some info about what apps expect from setting
the SO_LINGER option with a non-zero linger time on a TCP socket.
Suppose after the specified linger timeout, some data still cannot
be sent or some data has not been ack'ed by the peer.  In this
case, the close() will return an error as documented.  But what do
apps expect the underlying TCP connection will behave?  AFAIK,
there is no Solaris document which states what will happen to
the underlying TCP connection.  Do apps expect that the connection
will be aborted after the timeout, the same behavior if a zero linger
time is set?

Yes of course. And Oracle does seem to describe the behavior in both Java and Solaris documentation.

http://download.oracle.com/javase/1,5.0/docs/api/java/net/SocketOptions.html#SO_LINGER


     SO_LINGER

static final int *SO_LINGER*

   Specify a linger-on-close timeout. This option disables/enables
   immediate return from a *close()* of a TCP Socket. Enabling this
   option with a non-zero Integer /timeout/ means that a *close()* will
   block pending the transmission and acknowledgement of all data
   written to the peer, at which point the socket is closed
   /gracefully/. *Upon reaching the linger timeout, the socket is
   closed /forcefully/*, with a TCP RST. Enabling the option with a
   timeout of zero does a forceful close immediately. If the specified
   timeout value exceeds 65,535 it will be reduced to 65,535.

   Valid only for TCP: SocketImpl

   *See Also:*

Solaris: setsockopt(3SOCKET)

    The SO_LINGER option controls the action taken  when  unsent
    messages are queued on a socket and a close(2) is performed.
    If  the  socket  promises  reliable  delivery  of  data  and
    SO_LINGER  is  set,  the system will block the thread on the
    close() attempt until it is able to  transmit  the  data  *or
    until  it decides it is unable to deliver the information (a
    timeout period, termed the linger interval, is specified  in
    the  setsockopt()  call  when  SO_LINGER  is  requested)*. If
    SO_LINGER is disabled and a close() is  issued,  the  system
    will  process the close() in a manner that allows the thread
    to continue as quickly as possible.

Rao.
_______________________________________________
networking-discuss mailing list
networking-discuss@opensolaris.org

Reply via email to