c - socket control to accept multiple UDP connections -


i'm breaking mind trying understand how make client/server write myself accept multiple socket connections.

the connection datagram (udp), implemented based on getaddrinfo(3) man page works nice, each client needs wait process of connections processed.

i've heard select, in man page says:

select() can used solve many problems in portable , efficient way naive programmers try solve in more complicated manner using threads, forking, ipcs, signals, memory sharing, , on.

and more:

the linux-specific epoll(7) api provides interface more efficient select(2) , poll(2) when monitoring large numbers of file descriptors.

so, is? epoll better select? or depends? if depends, on what?

epoll man pages has partial sample, i'm trying understand it.

at now, (on server) think, need thread listen in thread , write in another. how control completion of partial message? if 2 clients send partial message interleaved, how identify? sockaddr? if it's need, can manage without pool, why use epoll?

can try explain me, how make, or learn multi-connection client-server udp app?

i think there misunderstanding here udp. udp not connection oriented protocol means there no permanent connection tcp. udp bind address/port , waits packets everyone. @ server there 1 socket listening per address/port number. when packet received may find out sender packet's source ip, can reply sender thru ip.

as see it, there no need poll() o select() bind address/port , asynchronously receive packets. is, when packet received signal/message alerting asynchronous function. function should reentrant, means in middle of reception signal received , care must taken when accessing/modifying global stuff (variables/objects). when dealing incoming packet should processed possible or, in case process takes long, better keep packet in packet spool , process them in [less priority] thread.

for udp packet size read this question.

for udp fragmentation read this

for udp packet header read this


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -