Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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
Python 拒绝连接_Python_Sockets - Fatal编程技术网

Python 拒绝连接

Python 拒绝连接,python,sockets,Python,Sockets,导致以下问题的原因: >>> s = socket(AF_INET, SOCK_STREAM) >>> s <socket._socketobject object at 0x104a7a670> >>> gethostname() 'MacBook-Air-user.local' >>> s.connect((gethostname(), 4444)) Traceback (most recent call l

导致以下问题的原因:

>>> s = socket(AF_INET, SOCK_STREAM)
>>> s
<socket._socketobject object at 0x104a7a670>
>>> gethostname()
'MacBook-Air-user.local'
>>> s.connect((gethostname(), 4444))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 61] Connection refused
>>> s.connect((gethostname(), 4444))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 22] Invalid argument
>>> s.bind((gethostname(), 4446))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 22] Invalid argument

您正试图在端口4444上打开与计算机的网络连接,但该端口上没有正在侦听的服务器


请参见位于

的套接字示例。您正试图在端口4444上打开与计算机的网络连接,但该端口上没有正在侦听的服务器


请参阅位于

的套接字示例,它应该是。

它应该是。

该端口上没有侦听,或防火墙/连接问题。该端口上没有侦听,或防火墙/连接问题。
MacBook-Air-user:source user$ uname -a
Darwin MacBook-Air-user.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64