23 lines
495 B
Python
23 lines
495 B
Python
import socket
|
|
|
|
|
|
data = """
|
|
{
|
|
"url": "/start"
|
|
}
|
|
""".encode('utf-8')
|
|
|
|
with open('./ips.txt', 'r') as f:
|
|
for ip in f.readlines():
|
|
print(ip.strip())
|
|
try:
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
s.settimeout(5)
|
|
# 发送数据:
|
|
s.sendto(data, (ip.strip(), 6001))
|
|
# 接收数据:
|
|
print(s.recv(1024).decode('utf-8'))
|
|
s.close()
|
|
except Exception as e:
|
|
print(e)
|