VirtualBox

Changeset 100171 in vbox for trunk/include


Ignore:
Timestamp:
Jun 13, 2023 9:07:56 PM (18 months ago)
Author:
vboxsync
Message:

IPRT: tcp.h+tcp.cpp,socket.h+socket.cpp: Add RTTcpSetKeepAlive() which
allows one to enable or disable sending periodic keep-alive messages on
a socket (SO_KEEPALIVE) as described in RFC 1122. RTTcpSetKeepAlive()
also allows one to adjust several keep-alive options on a per-socket
basis: the idle time before keep-alive probes are sent (TCP_KEEPIDLE
(TCP_KEEPALIVE on macOS)), the amount of time between keep-alive probes
(TCP_KEEPINTVL), and the number of keep-alive probes to send before
closing the connection (TCP_KEEPCNT).

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r100037 r100171  
    24722472# define RTTcpServerListen2                             RT_MANGLER(RTTcpServerListen2)
    24732473# define RTTcpServerShutdown                            RT_MANGLER(RTTcpServerShutdown)
     2474# define RTTcpSetBufferSize                             RT_MANGLER(RTTcpSetBufferSize)
     2475# define RTTcpSetKeepAlive                              RT_MANGLER(RTTcpSetKeepAlive)
    24742476# define RTTcpSetSendCoalescing                         RT_MANGLER(RTTcpSetSendCoalescing)
    2475 # define RTTcpSetBufferSize                             RT_MANGLER(RTTcpSetBufferSize)
    24762477# define RTTcpSgWrite                                   RT_MANGLER(RTTcpSgWrite)
    24772478# define RTTcpSgWriteL                                  RT_MANGLER(RTTcpSgWriteL)
  • trunk/include/iprt/tcp.h

    r98103 r100171  
    310310
    311311/**
     312 * Enables or disables sending of periodic keep-alive messages on a socket.
     313 * Also set values relating to TCP keep-alive messages on a socket.  The TCP
     314 * keep-alive mechanism is described in RFC 1122 which states:
     315 * "Keep-alive packets MUST only be sent when no data or acknowledgement
     316 * packets have been received for the connection within an interval. This
     317 * interval MUST be configurable and MUST default to no less than two hours."
     318 * The following per-socket options allow fine-tuning the keep-alive interval,
     319 * frequency, and timeout when SO_KEEPALIVE has been set for the socket.
     320 *
     321 * @returns iprt status code.
     322 * @retval  VERR_NOT_SUPPORTED is returned if these keep-alive options aren't
     323 *          supported by the OS.
     324 *
     325 * @param   hSocket                 Socket descriptor.
     326 * @param   fEnable                 When set to true enables keep-alive messages.
     327 * @param   cSecsIdle               The amount of time, in seconds, that the connection must be idle before
     328 *                                  keep-alive probes are sent for this socket. (TCP_KEEPIDLE (TCP_KEEPALIVE on macOS))
     329 *                                  If zero then the system default is used (the default value varies by OS
     330 *                                  but is typically 2 hours (7200 seconds)).
     331 * @param   cSecsInterval           The amount of time, in seconds, between each keep-alive probe sent to a
     332 *                                  peer. (TCP_KEEPINTVL)
     333 *                                  If zero then the system default is used (the default value varies by OS
     334 *                                  but is typically 75 seconds).
     335 * @param   cFailedPktsBeforeClose  The number of keep-alive probes to send which receive no response before
     336 *                                  closing the connection. (TCP_KEEPCNT)
     337 *                                  If zero then the system default is used (the default value varies by OS
     338 *                                  but is typically 8 packets).
     339 */
     340RTR3DECL(int)  RTTcpSetKeepAlive(RTSOCKET hSocket, bool fEnable, uint32_t cSecsIdle, uint32_t cSecsInterval,
     341                                 uint32_t cFailedPktsBeforeClose);
     342
     343/**
    312344 * Socket I/O multiplexing.
    313345 * Checks if the socket is ready for reading.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette