Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 当我中断telnet客户端时,端口关闭_Linux_Sockets_Networking - Fatal编程技术网

Linux 当我中断telnet客户端时,端口关闭

Linux 当我中断telnet客户端时,端口关闭,linux,sockets,networking,Linux,Sockets,Networking,我使用nc-l-p 9999和另一台机器上的telnet Server1 9999来启动Server1上的一个侦听端口,以建立连接 我想知道为什么我停止telnet客户端,然后端口也关闭。您需要使用-k标志 摘自nc手册页: -k, --keep-open (Accept multiple connections) . Normally a listening server accepts only one connection and then quits w

我使用
nc-l-p 9999
和另一台机器上的
telnet Server1 9999
来启动Server1上的一个侦听端口,以建立连接


我想知道为什么我停止telnet客户端,然后端口也关闭。

您需要使用-k标志

摘自nc手册页:

   -k, --keep-open (Accept multiple connections) .
       Normally a listening server accepts only one connection and then
       quits when the connection is closed. This option makes it accept
       multiple simultaneous connections and wait for more connections
       after they have all been closed. It must be combined with --listen.
       In this mode there is no way for Ncat to know when its network
       input is finished, so it will keep running until interrupted. This
       also means that it will never close its output stream, so any
       program reading from Ncat and looking for end-of-file will also
       hang.

非常感谢!但我仍然好奇端口如何知道连接中断?是因为此连接基于TCP协议吗?是的,连接状态将从已建立更改为关闭等待或侦听。