答案1
我找到了原因,这是TCP 客户端自我连接。
如果你运行以下 Bourne shell 代码片段:
while true do telnet 127.0.0.1 50000 done
您将不断收到消息
Connection refused
,但在某一时刻,连接将建立,并且您输入的任何内容都将被回显:Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. test1 test1 test2 test2
请注意,您没有启动任何服务器,并且本地主机上没有任何进程在监听端口 50000,但它却连接上了!查看
netstat
命令的输出,我们可以看到确实建立了连接:$ netstat -tn | grep 50000 tcp 0 0 127.0.0.1:50000 127.0.0.1:50000 ESTABLISHED