setsockopt 的源代码
哪位大大知道setsockopt的源代码是怎么实现的?帮忙说说
谢过先
[解决办法]
你是要setsockopt的源代码
还是要弄通他是什么实现的啊
[解决办法]
/*******************************************************************************
*
* setsockopt - set socket options
*
* This routine sets the options associated with a socket.
* To manipulate options at the "socket" level, <level> should be SOL_SOCKET.
* Any other levels should use the appropriate protocol number.
*
* OPTIONS FOR STREAM SOCKETS
* The following sections discuss the socket options available for
* stream (TCP) sockets.
*
* .SS "SO_KEEPALIVE -- Detecting a Dead Connection"
* Specify the SO_KEEPALIVE option to make the transport protocol (TCP)
* initiate a timer to detect a dead connection:
* .CS
* setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof (optval));
* .CE
* This prevents an application from hanging on an invalid connection.
* The value at <optval> for this option is an integer (type `int'),
* either 1 (on) or 0 (off).
*
* The integrity of a connection is verified by transmitting
* zero-length TCP segments triggered by a timer, to force a response
* from a peer node. If the peer does not respond after repeated
* transmissions of the KEEPALIVE segments, the connection is dropped,
* all protocol data structures are reclaimed, and processes sleeping
* on the connection are awakened with an ETIMEDOUT error.
*
* The ETIMEDOUT timeout can happen in two ways. If the connection is
* not yet established, the KEEPALIVE timer expires after idling
* for TCPTV_KEEP_INIT. If the connection is established, the
* KEEPALIVE timer starts up when there is no traffic for
* TCPTV_KEEP_IDLE. If no response is received from the peer after
* sending the KEEPALIVE segment TCPTV_KEEPCNT times with interval
* TCPTV_KEEPINTVL, TCP assumes that the connection is invalid.
* The TCPTV_KEEP_INIT, TCPTV_KEEP_IDLE, TCPTV_KEEPCNT, and TCPTV_KEEPINTVL
* parameters are defined in the file target/h/netinet/tcp_timer.h.
*
* .SS "SO_LINGER -- Closing a Connection"
* Specify the SO_LINGER option to determine whether TCP should perform a
* "graceful" close:
* .CS
* setsockopt (sock, SOL_SOCKET, SO_LINGER, &optval, sizeof (optval));
* .CE
* To achieve a "graceful" close in response to the shutdown of a connection,
* TCP puts itself through an elaborate set of state transitions. The goal is
* to assure that all the unacknowledged data in the transmission channel are
* acknowledged, and that the peer is shut down properly.