Similar to How to set source address when sending using and UDP socket, but not identical:
I'm writing an experimental UDP packet relay. The code works so far, but the problem is that the relayed packets have the address and port of the relay (instead of the original sender) as sending address in the outgoing packets, so any responses would also go to the relay, and not to the original sender.
Is there a standard way (without manipulating the packets directly) to do this? Currently it has to work for IPv4 only.