I've been trying to test UDP hole punching in Python and it seems that the message is not received by the other client.
Is there a possible solution to this?
Here is the code:
from socket import *
from _thread import start_new_thread
from sys import argv
from time import sleep
PORT = 50000 + int(argv[1])
sock = socket(AF_INET, SOCK_DGRAM)
sock.bind(("0.0.0.0", PORT))
def read():
while True:
print(sock.recvfrom(1024))
start_new_thread(read, ())
while True:
sock.sendto(b"0", ("<my ip>", [50002, 50001][PORT-50001]))
sleep(1)
Both are on the same network, as I do not own multiple networks to test, but are attempting to communicate through the public IP, but they do not seem to actually receive the message. I expected to receive messages and establish a hole punch, but it does not seem like that is working.