当前位置: 技术问答>linux和unix
套接字选项问题
来源: 互联网 发布时间:2017-02-18
本文导语: SO-KEEPALIVE SO-LINGER SE-RCVBUF 和 SO-SNDBUF SO-RCVWAT和 SO-SNDLOWAT SO-RCVTIMEO和 SO-SNDTIMEO SO-REUSEADDR和 SO-REUSPORT IP-TTL TCP-KEEPALIVE ,那位大侠解释一下这些参数的作用,和具体有什么用? 当UDP通信时,是不是为了防止数据丢...
SO-KEEPALIVE SO-LINGER SE-RCVBUF 和 SO-SNDBUF SO-RCVWAT和 SO-SNDLOWAT SO-RCVTIMEO和 SO-SNDTIMEO SO-REUSEADDR和 SO-REUSPORT IP-TTL TCP-KEEPALIVE
,那位大侠解释一下这些参数的作用,和具体有什么用?
当UDP通信时,是不是为了防止数据丢失,可以同SE-RCVBUF 和 SO-SNDBUF 来调整接收buffer,保证数据不会丢失,谢谢!
,那位大侠解释一下这些参数的作用,和具体有什么用?
当UDP通信时,是不是为了防止数据丢失,可以同SE-RCVBUF 和 SO-SNDBUF 来调整接收buffer,保证数据不会丢失,谢谢!
|
详见:http://man7.org/linux/man-pages/man7/socket.7.html
摘要:
SO_KEEPALIVE
Enable sending of keep-alive messages on connection-oriented sockets.
Expects an integer boolean flag.
SO_LINGER
Sets or gets the SO_LINGER option. The argument is a linger structure.
struct linger {
int l_onoff; /* linger active */
int l_linger; /* how many seconds to linger for */
};
When enabled, a close(2) or shutdown(2) will not return until all
queued messages for the socket have been successfully sent or the
linger timeout has been reached. Otherwise, the call returns
immediately and the closing is done in the background. When the socket
is closed as part of exit(2), it always lingers in the background.
摘要:
SO_KEEPALIVE
Enable sending of keep-alive messages on connection-oriented sockets.
Expects an integer boolean flag.
SO_LINGER
Sets or gets the SO_LINGER option. The argument is a linger structure.
struct linger {
int l_onoff; /* linger active */
int l_linger; /* how many seconds to linger for */
};
When enabled, a close(2) or shutdown(2) will not return until all
queued messages for the socket have been successfully sent or the
linger timeout has been reached. Otherwise, the call returns
immediately and the closing is done in the background. When the socket
is closed as part of exit(2), it always lingers in the background.
|
man 7 socket