from socket import socket, AF_INET, SOCK_DGRAM
sock = socket(AF_INET, SOCK_DGRAM)
sock.sendto('hello'.encode(), ('192.168.100.42', 12500))
以及接收方的代码:
from socket import socket , SOCK_DGRAM, AF_INET
sock = socket(AF_INET, SOCK_DGRAM)
sock.bind(('192.168.100.42', 12500))
data, addr = sock.recvfrom(100)
print('a massage has been received !', addr, data)
我不明白为什么它什么都没得到,仅提及我确定IP是正确的,我已经打开了CMD并输入了:
ipconfig
无论如何,谢谢大家。