python socket error: [Errno 10053]?
python初学者,刚学到网络编程,运行下面小程序的时候报error:[Errno10053]错:server部分程序:importsockets=socket.sock...
python初学者,刚学到网络编程,运行下面小程序的时候报error: [Errno 10053]错:
server部分程序:
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('localhost',8001))
s.listen(5)
while True:
c,addr=s.accept()
try:
c.settimeout(5)
buf=c.recv(1024)
if buf=='1':
c.send('Welcome to server!')
else:
c.send('Please go out!')
except socket.timeout:
print 'Time Out!'
c.close()
client部分代码:
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('localhost',8001))
import time
time.sleep(2)
s.send('1')
print s.recv(1024)
s.close()
先运行服务器然后客户机,一直报下面这个错误,是为什么啊?求解。
>>> ================================ RESTART ================================
>>>
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "D:/python2.7.6/client", line 7, in <module>
print s.recv(1024)
error: [Errno 10053] 展开
server部分程序:
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('localhost',8001))
s.listen(5)
while True:
c,addr=s.accept()
try:
c.settimeout(5)
buf=c.recv(1024)
if buf=='1':
c.send('Welcome to server!')
else:
c.send('Please go out!')
except socket.timeout:
print 'Time Out!'
c.close()
client部分代码:
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('localhost',8001))
import time
time.sleep(2)
s.send('1')
print s.recv(1024)
s.close()
先运行服务器然后客户机,一直报下面这个错误,是为什么啊?求解。
>>> ================================ RESTART ================================
>>>
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "D:/python2.7.6/client", line 7, in <module>
print s.recv(1024)
error: [Errno 10053] 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询