为什么客户端应用程序后,客户端服务器等待已投入处于停止状态? [英] Why server waits for a client after the client application has been put in STOPPED state?

查看:164
本文介绍了为什么客户端应用程序后,客户端服务器等待已投入处于停止状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是一个扩展以<一个href=\"http://stackoverflow.com/questions/18307828/how-to-detect-that-the-client-is-still-connected-and-not-hung-up-using-recv\">this previously问问题:

我实现由下式给出的解决方案的 JXH 具有以下PARAMS:

I implemented the solution given by jxh with following params:

SO_KEEPALIVE = Enabled  
TCP_KEEPIDLE = 120 secs  
TCP_KEEPINTVL = 75 secs  
TCP_KEEPCNT = 1

那么,为什么服务器仍在等待永远为客户应对?

Then why the server still waits forever for client to respond?

此外,我发现互联网上

杀&LT; PID&GT; 实际发送 SIGTERM 给定的过程。

kill <pid> actually sends SIGTERM to the given process.

所以我用 PS -o PID,CMD,状态后命令'杀人'的Telnet应用程序。

So I used ps -o pid,cmd,state command after 'killing' the telnet application.

我看到的telnet进程仍然存在,但与进程状态= T ,即它是在已停止状态

I saw that the telnet process was still there but with process state = T, i.e. it was in STOPPED state

P.S:我没有Linux信号的多少知识,请考虑

P.S.: I do not have much knowledge of Linux Signals, please consider that.

推荐答案

由于客户端进程仍然活着,那么在内核的TCP协议栈将处理它的确认数据包接收回发件人的保活包该分组。所以,即使在连接确实空闲时,该连接将永远不会被关闭,因为内核愉快地处理该数据包。

Since the client processes are still alive, then the TCP stack in the kernel will process the keep-alive packets it receives with an acknowledgement packet back to the sender of the packet. So, even though the connection is indeed idle, the connection will never be closed since the kernel is happily processing the packets.

在实际网络中,如果从客户机到ACK曾经迷路的连接将被关闭。在你的设置,因为客户端和服务器位于同一台机器上,你的网络将基本无损的。

On a real network, given your parameters, the connection would be closed if the ACK from the client machine ever got lost. On your setup, since the client and server are on the same machine, your network will be essentially lossless.

这我不清楚你如何在这种状态下有你的远程登录会话。 SIGTERM 不会把一个进程处于停止状态。接收 SIGSTOP (通常 SIGTSTP ,但似乎远程登录时,过程进入停止状态忽略了一个)。我建议也许你发送了信号的错误,或者暂停会议(与 ^】Z )。当发生这种情况,你应该已经看到在窗口,一个与你的telnet会话,产生这样的输出:

It is unclear to me how you got your telnet sessions in this state. SIGTERM will not put a process in the stopped state. The process goes into stopped state when receiving SIGSTOP (and usually SIGTSTP, but it seems telnet ignores that one). I suggest that perhaps you sent that signal by mistake, or you suspended the session (with ^]z). When that happened, you should have seen in the window, the one with your telnet session, generate output like:

[1]+  Stopped                 telnet ...

这是由shell打印。当远程登录过程停止,也不会处理 SIGTERM ,直到它被放置在前台后。

This is printed by the shell. When the telnet process is stopped, it won't process the SIGTERM until after it is placed in the foreground.

A SIGKILL (用做杀-9 LT; PID&GT; )将立即处理。

A SIGKILL (done with kill -9 <pid>) will be processed immediately.

这篇关于为什么客户端应用程序后,客户端服务器等待已投入处于停止状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆