当前位置: 代码迷 >> 应用服务器 >> 用python写了接受链接的程序,求高数指点里面的异常
  详细解决方案

用python写了接受链接的程序,求高数指点里面的异常

热度:8784   发布时间:2013-02-26 00:00:00.0
用python写了接受链接的程序,求高数指点里面的错误
import socket
host='222.135.146.245'
port=20438
addr=(host,port)
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.bind(addr)
print "Waiting for connections..."
s.listen(1)
while 1:
  clientsock,clientaddr=s.accept()
  print"Got connection from",clientsock.getpeername()
  clientsock.close()
   
Traceback (most recent call last):
  File "C:/Python27/点到系统/实验.py", line 7, in <module>
  s.bind(addr)
  File "C:\Python27\lib\socket.py", line 222, in meth
  return getattr(self._sock,name)(*args)
error: [Errno 10049]

------解决方案--------------------------------------------------------
C:\Python27\lib\socket.py

socket 的bind 方法是怎样的?