import socket
print(socket.gethostbyname(socket.gethostname()));
TCP_IP = "192.168.56.1";
TCP_PORT = 8080;
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
s.bind((TCP_IP, TCP_PORT));
conn, addr = s.accept();
print('Connection address:' + addr);
while 1:
print("Started: ");
data = conn.recv(20);
if not data: break
print ("received data:", data);
conn.send(data);
conn.close();
考虑以下代码,我正在尝试在Python上设置WIFi TCP服务器。但是由于某种原因,运行输出时,我得到的是:
Traceback (most recent call last):
File "C:/Users/Yoga/PycharmProjects/untitled/exec", line 10, in <module>
conn, addr = s.accept();
File "C:\Users\Yoga\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 212, in accept
fd, addr = self._accept()
OSError: [WinError 10022] An invalid argument was supplied
显然,socket.py
中存在某种错误。欢迎提出如何修复的建议。