【问题标题】:Python Socket bound on 0.0.0.0, can't connect via 127.0.0.1Python Socket 绑定在 0.0.0.0,无法通过 127.0.0.1 连接
【发布时间】:2013-01-11 15:43:37
【问题描述】:

我有一台运行绑定到 0.0.0.0:8000 的 Python XMLRPCServer 的 Windows XPSP3 机器,但是当我尝试通过地址 127.0.0.1:8000 上的 httplib HTTPConnection 进行连接时,我收到 socket.connection 错误,errno 10107(未知错误)。

C:\Documents and Settings\Matt>netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       940
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       1244
  TCP    0.0.0.0:8000           0.0.0.0:0              LISTENING       3624
  TCP    0.0.0.0:10049          0.0.0.0:0              LISTENING       1184
  TCP    127.0.0.1:1028         0.0.0.0:0              LISTENING       2644
  TCP    192.168.80.132:139     0.0.0.0:0              LISTENING       4
  UDP    0.0.0.0:445            *:*                                    4
  UDP    0.0.0.0:500            *:*                                    696
  UDP    0.0.0.0:1025           *:*                                    1096
  UDP    0.0.0.0:4500           *:*                                    696
  UDP    127.0.0.1:123          *:*                                    1040
  UDP    127.0.0.1:1900         *:*                                    1252
  UDP    192.168.80.132:123     *:*                                    1040
  UDP    192.168.80.132:137     *:*                                    4
  UDP    192.168.80.132:138     *:*                                    4
  UDP    192.168.80.132:1900    *:*                                    1252

C:\Documents and Settings\Matt>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib
>>> h1 = httplib.HTTPConnection('127.0.0.1:8000')
>>> h1.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\httplib.py", line 757, in connect
    self.timeout, self.source_address)
  File "C:\Python27\lib\socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 10107] A system call that should never fail has failed
>>> h1 = httplib.HTTPConnection('192.168.80.132:8000')
>>> h1.connect()
>>> 

编辑:它在代码块中,但我忘了实际提及它。如果我尝试通过机器的IP地址(192.168.80.132)连接,它连接成功。

关于更多上下文,这实际上发生在 Cuckoo Sandbox Analyzer.py 脚本的一个实例中,但我已经能够重新创建上述错误,所以我认为这不是 Cuckoo 的问题,但是与 Windows 套接字。感谢您为此提供的任何帮助。

【问题讨论】:

  • 如果你执行 'ping -a 127.0.0.1' 会成功反转到你的主机名吗?
  • 它解析为 localhost,但不是我的主机名 (winxp-vm)。
  • C:\Documents and Settings\Matt>ping -a 127.0.0.1 Ping localhost [127.0.0.1] 32 字节数据:来自 127.0.0.1 的回复:字节=32 时间
  • 尝试在机器上打开一个 DOS 窗口并运行“telnet 127.0.0.1 8000”。如果 telnet 连接,则服务器正在侦听端口 8000,因此问题可能出在客户端(httplib)端。另一方面,如果您收到“连接被拒绝”,则服务器未在端口 8000 上侦听,因此问题出在服务器端。
  • C:\Documents and Settings\Matt&gt;telnet 127.0.0.1 8000 Connecting To 127.0.0.1...Could not open connection to the host, on port 8000. The system cannot find the file specified.

标签: python windows sockets


【解决方案1】:

结果证明这是我进行的另一次系统修改的结果。这是在恶意软件分析沙箱上,我安装了一个用于监控低级网络流量的工具。即使我卸载了该工具,它也安装了一个持续存在的分层服务提供程序。我删除了那些 LSP,一切正常。

【讨论】:

    猜你喜欢
    • 2019-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多