You would need to keep track of your incoming and outgoing addresses (ingress/egress). When reading from the incoming socket you could use a list or a dict of outgoing connections to relay the message back out.
I though of that but while the ip stays the same but the port changes every message so I don't know how to move foward