免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1986 | 回复: 2
打印 上一主题 下一主题

[函数] 求教listen backlog参数难道无效? [复制链接]

论坛徽章:
7
天蝎座
日期:2013-09-28 10:45:42双子座
日期:2013-10-16 16:27:09射手座
日期:2013-10-23 10:21:32处女座
日期:2014-09-17 16:44:332015年亚洲杯之巴林
日期:2015-04-09 17:28:01冥斗士
日期:2015-11-26 16:19:0015-16赛季CBA联赛之山东
日期:2018-03-02 23:59:31
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-04-15 09:43 |只看该作者 |倒序浏览
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。

这是什么情况?

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
2 [报告]
发表于 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.

论坛徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46处女座
日期:2013-10-24 14:25:01酉鸡
日期:2014-04-07 11:54:15
3 [报告]
发表于 2013-04-15 13:24 |只看该作者
只是建议值.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP