1
votes

I have a multi threaded python application communicating with a separate service trough UDP.

Each thread is similar, at some point need a response from the separate service.

So practically for each thread I create e new client socket and start to communicate. The problem is on the server side each UDP packet seems to come from the same reception port thus this create problem on the client side on who receives whose message.

How can I enforce the socket to use a different ephemeral reception port for each instance in the same program different threads?

Thanks!

1
is this on a local LAN or through some NAT mechanism?Not_a_Golfer
it is on local LAN, err it is an ubuntu vmware machine with the network interface set to 'bridged'.sanyi

1 Answers

2
votes

You can connect() each UDP socket to it's target. That way the ephemeral ports will be fixed (and different) for each thread.