I have a UDP server in C based on libuv
, we have a :
- Main Thread : that receives an UDP packet that and enqueues it to one of the 4 queues and invokes a dequeue callback to one of the 4 workers. The main thread is
bind()
to port 9930 - 4 Worker Threads : dequeues from the respective queue on callback invocation and sends back a response. Each thread also binds to the same address
Now, when i send request (src_port:A
and dest_port:9930
) to the UDP server , the server responds with a UDP packet with src_port:B
and dest_port:A
. I want B to be equal to 9930.
I went through some articles online and set UV_UDP_REUSEADDR
flag in uv_udp_bind()
for both the main thread and in the 4 worker thread. But, now the udp server doesn't always accept the request, not even the receive callbacks are invoked. It does sometimes and for these cases the flow is proper with port B=9930
.