如何在 python 中使用套接字模块连接到另一台电脑?我的代码目前给了我 2 个错误。第一个错误是:
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it.
line 7, in <module>
s.connect((target, 80))**
这是我的代码:
import socket
target = '192.168.1.0' #i convered the full ip
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((target, 80))
s.send('HEAD / HTTP/1.1\nHost: ' + target + '\n\n')
print (s.recv(1024))
s.close()