2 qq 26898723 qq_26898723 于 2015.06.11 14:18 提问

关于TCP中的【backlog】疑问

《TCP/IP详解卷1 协议》第2版中写道:

Linux% sock -s -v -q1 -O30000 6666

The -q1 option sets the backlog of the listening endpoint to 1.The -O30000
option causes the program to sleep for 30,000s(basically a long time,about 8
hours) before accepting any client connections.If we now try to connect to this
server continually,the first four connections are completed immediately.After
that,two connections are completed every 9s.Other operating systems vary
considerably in how this is handled.In Solaris 8 and FreeBSD 4.7,for example,
two connections are handled immediately and the third times out;subsequent
connections time out as well.

我不懂的是命令设置了backlog=1,那么后面的

"If we now try to connect to this server continually,the first four connections
are completed immediately.After that,two connections are completed every 9s."

"In Solaris 8 and FreeBSD 4.7,for example,
two connections are handled immediately and the third times out"
是怎么回事?

求详解,谢谢大神!

3个回答

oyljerry
oyljerry   Ds   Rxr 2015.06.11 19:57

因为backlog =1 那么,你的第一个连接可以马上处理,而第二个放到backlog中,但是第三个来的时候就会超时丢掉了

qq_26898723
qq_26898723 那么这句怎么解释呢?"If we now try to connect to this server continually,the first four connections are completed immediately.After that,two connections are completed every 9s."
2 年多之前 回复
qq_26898723
qq_26898723 那么这句怎么解释呢?"If we now try to connect to this server continually,the first four connections are completed immediately.After that,two connections are completed every 9s."
2 年多之前 回复
nswcfd
nswcfd   2015.06.12 12:48

参见18.11节,Incoming Connection Request Queue

The Solaris values in this figure are what we expect. The traditional BSD values are (for some unknown reason) the backlog value times 3, divided by 2, plus 1.

qq_26898723
qq_26898723 "If we now try to connect to this server continually,the first four connections are completed immediately.After that,two connections are completed every 9s" 还有这个情况不是很清楚,可以解释一下吗?谢谢
2 年多之前 回复
qq_26898723
qq_26898723 我看了第一版的18.11节,是不是说backlog这个值不等于队列的值,队列的值是根据backlog的值计算得到的?
2 年多之前 回复
nswcfd
nswcfd   2015.06.12 12:56

不好意思,才注意到你是在说第二版(linux实现)

Csdn user default icon
上传中...
上传图片
插入图片