I have a problem with UDP messages under Python3 on Windows10.
The UDP messages are a command/response scheme.
- Example: CMD_TURN_ON_LIGHT_BULB, Bulb #4
- Response: RSP_TURN_ON_LIGHT_BULB, Bulb #4 - OK.
My local Windows PC address is: 10.1.1.10
In all cases, the netmask here is 255.255.255.0
The remote device has 2 network addresses.
There are various routers between the PC and the remote device.
Device Address (A) is 10.2.2.10 (and is the "default route").
Device Address (B) is 10.3.3.10 (it is a backup interface)
Case 1: This works.
PC sends UDP to 10.2.2.10 (it uses "sendto()")
The remote device responds to the source address using sendto()
The PC receives the response, and the application receives the response.
The PC has a pending/waiting "recvfrom()"
Case 2: This does not work.
PC Sends UDP to 10.3.3.10 (the backup interface)
The remote device replies -
However - due to default route rules, the device replies from 10.2.2.10
The PC receives the reply (I see the reply/response in Wireshark)
The PC has the firewall 100% disabled
But - The application does not receive the UDP message from the remote device.
Any suggestions?
Stated differently:
- This works: Transmit to UPD address (A), Port X - reply from: A, port Y
- This fails: Transmit to UDP address (B), port X - reply from: A, port Y
The second case, the packet seems to be lost inside the bowels of Windows...
question from:
https://stackoverflow.com/questions/65602762/windows-sockets-udp-and-udp-replies-different-addresses 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…