What is the correct method to receive UDP data from several clients synchronously? -


i have 1 server , several (maybe 20) clients. clients sending udp datagram @ random time. each datagram quite short (about 10b), must make sure data each client received correctly.

if let clients send datagram same port, , client b sends datagram @ exact time when server receiving data client a, seems server miss data client a.

so what's correct method job? need create listener each of 20 clients?

when bind udp socket port, networking stack allocate buffer finite number of incoming udp packets you, (assuming call recv() in relatively timely manner), no incoming packets should lost.

if want see buffer size in terminal, can take at:

/proc/sys/net/core/rmem_default recv  

and

/proc/sys/net/core/wmem_default send 

i think default buffer size on linux 131071b.

on linux, can change udp buffer size (e.g. 26214400) (as root):

 sysctl -w net.core.rmem_max=26214400 

you can make permanent adding line /etc/sysctl.conf:

net.core.rmem_max=26214400 

since each packet 10b, shouldnt problem.

if still worried packet loss implement protocol client waits ack server or resend. many protocols use such feature, possible if timing allows it. example in streaming data not useful because there no time resend.

or consider using tcp ( if option)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -