6
回答
linux下最简单的socket客户端报错
华为云数据库免费试用   
同样的程序,同样的IDE,同样的python2.7,在windows下可以正常运行,linux下就不行!为什么呢? server没有问题,就client有问题! 
原帖:

http://www.pythontab.com/html/20 ... cheng_0427/377.html

#!/usr/bin/env python
import socket
import time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 8002))
time.sleep(2)
s.send("1")
print s.recv(1024)
s.close()
/usr/bin/python2.7 /home/daniel/PycharmProjects/untitled/client.py
Traceback (most recent call last):
  File "/home/daniel/PycharmProjects/untitled/client.py", line 5, in <module>
    s.connect(('localhost', 8002))
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

Process finished with exit code 1
举报
hawkingyy
发帖于2年前 6回/534阅
顶部