Hi everybody,
I'm developping a ESP32-project where the ESP32 is broadcasting UDP-messages in a certain mode.
With setting up the IP-adress as broadcasting to the local network
X.X.X.255
and as remoteport 4210
int remotePort = 4210;
...
Udp.beginPacket(broadcastIP, remotePort);
Udp.write((const uint8_t*)UDP_Msg_SS.c_str(), UDP_Msg_SS.length() );
Udp.endPacket();
I can receive the UDP-messages on my PC with a python script that uses the same port
udp_host = socket.gethostname() # Host IP
udp_port = 4210 # specified port to connect
print("udp_host",udp_host)
sock.bind((udp_host,udp_port))
print ("Waiting for client...")
and I can receive the messages on my smartphone with an UDP-receiver-App
but what I find weird is that the if I print the port
# python-script
data,addr = sock.recvfrom(1024) #receive data from client
print("data #",data,"#")
Msg = data.decode('utf-8')
print ("Received Message: #",Msg,"# from",addr)
there is a completely different portnumber
I defined 4210 and what is printed is 51206 !
Received Message: # ESP-IP=192.168.178.186 # from ('192.168.178.186', 51206)
and it is the same on the smartphone
In the settings I enter port 4210
I receive the messages but the port is this 51206
on smartphone
[192.168.178.186:51206]"ESP-IP=192.168.178"
Huh? can somebody explain this to me?