执行这个socket客户端。出错:error: [Errno 10053]
1。
#应用实例的服务器端import socket;sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); #生成Socket对像sock.bind(('localhost', 8001)); #绑定主机IP与端口号sock.listen(5); #开始监听while True: connection, address = sock.accept(); # try: connection.settimeout(5); #在5秒后调用这个函数 buf = connection.recv(1024); if buf == '1': connection.send('lkafds'); else: connection.send('false'); except socket.timeout: print 'time out'; connection.close();sock.close();
#socket 小实例 客户端代码import socketimport timesock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); #sock.connect(('localhost', 8001)); #time.sleep(2);sock.send('1');print sock.recv(1024);sock.close();
Traceback (most recent call last): File "F:/python/pyweb/1.1.7.py", line 8, in <module> print sock.recv(1024);error: [Errno 10053]