我正在尝试将套接字与 python 一起使用,但我不断收到此错误消息:
import socket
>>> s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
>>> s.connect(('localhost', 8000))
Traceback (most recent call last):
File "stdin", line 1, in module
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused
/etc/hosts 中的配置是:
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
系统是 ubuntu 12.04 ,没有配置防火墙。尝试更改端口号,但没有运气;它仅适用于不同于“localhost”的域。有人知道为什么会这样吗?