prlinger.rst (1918B)
1 PRLinger 2 ======== 3 4 Structure used with the ``PR_SockOpt_Linger`` socket option to specify 5 the time interval (in :ref:`PRIntervalTime` units) to linger on closing a 6 socket if any data remain in the socket send buffer. 7 8 9 Syntax 10 ~~~~~~ 11 12 .. code:: 13 14 #include <prio.h> 15 16 typedef struct PRLinger { 17 PRBool polarity; 18 PRIntervalTime linger; 19 } PRLinger; 20 21 22 Fields 23 ~~~~~~ 24 25 The structure has the following fields: 26 27 ``polarity`` 28 Polarity of the option's setting: ``PR_FALSE`` means the option is 29 off, in which case the value of ``linger`` is ignored. ``PR_TRUE`` 30 means the option is on, and the value of ``linger`` will be used to 31 determine how long :ref:`PR_Close` waits before returning. 32 ``linger`` 33 Time (in :ref:`PRIntervalTime` units) to linger before closing if any 34 data remain in the socket send buffer. 35 36 37 Description 38 ~~~~~~~~~~~ 39 40 By default, :ref:`PR_Close` returns immediately, but if there are any data 41 remaining in the socket send buffer, the system attempts to deliver the 42 data to the peer. The ``PR_SockOpt_Linger`` socket option, with a value 43 represented by a structure of type :ref:`PRLinger`, makes it possible to 44 change this default as follows: 45 46 - If ``polarity`` is set to ``PR_FALSE``, :ref:`PR_Close` returns 47 immediately, but if there are any data remaining in the socket send 48 buffer, the runtime attempts to deliver the data to the peer. 49 - If ``polarity`` is set to ``PR_TRUE`` and ``linger`` is set to 0 50 (``PR_INTERVAL_NO_WAIT``), the runtime aborts the connection when it 51 is closed and discards any data remaining in the socket send buffer. 52 - If ``polarity`` is set to ``PR_TRUE`` and ``linger`` is nonzero, the 53 runtime *lingers* when the socket is closed. That is, if any data 54 remains in the socket send buffer, :ref:`PR_Close` blocks until either 55 all the data is sent and acknowledged by the peer or the interval 56 specified by ``linger`` expires.