Bee*_*ope 6 networking tcp netstat ports macos
我认为我提出的 Web 服务器进程正在侦听 localhost:8080,并尝试连接到它,但一直收到连接重置错误。事实证明,我错了,我的进程正在侦听一个完全不同的端口。
然而,我无法理解的是为什么我会收到连接重置错误,而不是如果没有进程在该端口上侦听,通常会得到“连接被拒绝”。据我所知,在 8080 上没有其他东西可以收听:
$ sudo lsof -i -P | grep 8080
# no result
$ sudo netstat -a -n | grep 8080
# still no result
Run Code Online (Sandbox Code Playgroud)
然而,最初接受与此端口的连接(尽管在进一步数据时关闭):
$ /usr/local/bin/wget localhost:8080
--2014-01-14 16:29:22-- http://localhost:8080/
Resolving localhost... ::1, 127.0.0.1, fe80::1
Connecting to localhost|::1|:8080... failed: Connection refused.
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... No data received.
Run Code Online (Sandbox Code Playgroud)
与 telnet 类似:
$ telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Run Code Online (Sandbox Code Playgroud)
尝试其他随机端口只会导致预期的连接被拒绝错误:
$ telnet localhost 8081
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host
Run Code Online (Sandbox Code Playgroud)
我的主机文件很简单:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6535 次 |
| 最近记录: |