Chinaunix

标题: 求教listen backlog参数难道无效? [打印本页]

作者: cxytz01    时间: 2013-04-15 09:43
标题: 求教listen backlog参数难道无效?
man listen

int listen(int sockfd, int backlog);

The  backlog parameter defines the maximum length the queue of pending connections may grow to.  If a connection request arrives with the queue
       full the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may
       be ignored so that retries succeed.

程序里backlog的值为1,也即监听队列为1,因此只允许有一个连接可以establish。
但,实际上,发现有3个连接establish。

这是什么情况?

作者: hellioncu    时间: 2013-04-15 10:56
NOTES
       The  behaviour  of the backlog parameter on TCP sockets changed with Linux 2.2.  Now it specifies the queue length for
       completely established sockets waiting to be accepted, instead of the number of incomplete  connection  requests.  The
       maximum  length  of the queue for incomplete sockets can be set using the tcp_max_syn_backlog sysctl.  When syncookies
       are enabled there is no logical maximum length and this sysctl setting is ignored.  See tcp(7) for more information.
作者: linux_c_py_php    时间: 2013-04-15 13:24
只是建议值.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2