原帖由 yhch 于 2005-11-6 13:11 发表
这个现象是正常的吧?如果Client死机的话Server不会知道的。Client重新开机后连接依然存在,仍然能正常通讯。如果是服务器死掉重新开机后,Client向Server发送数据,则服务器回应一个FIN断开连接。
我觉得定时在 ...
原帖由 yhch 于 2005-11-6 13:11 发表
这个现象是正常的吧?如果Client死机的话Server不会知道的。Client重新开机后连接依然存在,仍然能正常通讯。如果是服务器死掉重新开机后,Client向Server发送数据,则服务器回应一个FIN断开连接。
我觉得定时在 ...
原帖由 xiaofei104 于 2005-11-6 18:58 发表
1。因为我的Client/Server都是自己写的。所以我的做法是在Client中加了一个钩子去显示的close掉socket.而不是依赖于进程的关闭时候的资源释放。
2。你的情况可以试试将线程设置为守护线程,将socket资源设置为线程内的一个变量,而非一个全局的,在多个线程间共享的。
原帖由 wangshim_ 于 2005-11-7 11:14 发表
上面的哥们,我想问你们2个问题:
1,为什么client断了,server就能知道?,(另client可能是网络断、CTRL+C关闭进程等)
2,可以显示established,和你的多线程有什么关系?
这个完全和网络原理,与操作系统 ...
A socket is ready for reading if any of the following four conditions is true:
a.The number of bytes of data in the socket receive buffer is greater than
or equal to the current size of the low-water mark for the socket receive buffer.
A read operation on the socket will not block
and will return a value greater than 0 (i.e., the data that is ready to be read).
We can set this low-water mark using the SO_RCVLOWAT socket option.
It defaults to 1 for TCP and UDP sockets.
b.The read half of the connection is closed (i.e., a TCP connection that has received a FIN).
A read operation on the socket will not block and will return 0 (i.e., EOF).
c.The socket is a listening socket and the number of completed connections is nonzero.
An accept on the listening socket will normally not block,
although we will describe a timing condition in Section 16.6 under
which the accept can block.
d.A socket error is pending. A read operation on the socket will not block
and will return an error (–1) with errno set to the specific error condition.
These pending errors can also be fetched and cleared by calling getsockopt
and specifying the SO_ERROR socket option.
原帖由 柳五随风 于 2005-11-7 23:13 发表
除了wang说的部分正确以外,其他全错误.
client端在长连接情况下,如果没有write动作,那么session上没有数据流动,这种情况下,如果client crashed了,那么client 的os没有机会发送FIN报文,server是不知道client出事了 ...
原帖由 柳五随风 于 2005-11-9 22:50 发表
xiaofei 看看书先.
原帖由 xiaofei104 于 2005-11-10 10:23 发表
没有必要这样!有什么说的不对的敬请指教!
原帖由 柳五随风 于 2005-11-10 10:54 发表
ftp xxx
登录以后啥也别动直接把电源拔了,看看什么情况在说.
原帖由 zhanghua111 于 2005-11-5 22:07 发表
最近在linux下写了个http代理程序,代理是通过多线程实现的,后来进行压力测试后发现,客户端已经断开了所有的连接,但是在代理的机器上用netstat还能看到ESTABLISHED状态的连接存在,而且一些子线程也没有正常退 ...
原帖由 柳五随风 于 2005-11-11 11:34 发表
你怎么知道client是正常退出的?
client程序正常退出不代表client和server的拆会话的4步结束了.看看书再
client退出后,立即查看其socket状态,看看它什么状态.
我觉得很有可能是网络抖动引起的问题,比如线上 ...
原帖由 xiaofei104 于 2005-11-11 11:45 发表
我不很明确表示了吗?我的正常退出是指进程被用户用窗口右上方的Close按纽关闭,或是被kill pid给干了。在这种情况下操作系统应该给服务器发FIN来结束的。而且我们在这里的问题也很明确了提出对于这种情况下的 ...
原帖由 柳五随风 于 2005-11-11 12:06 发表
说明你看不懂我在说什么.完成了4步close,server上能不正常?奇怪的很呢.
在这种情况下操作系统应该给服务器发FIN来结束的。
---失败了怎么办?超过N次失败呢?
如果你的问题发生的很频繁,用类似tcpdump这样 ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |