How to use boost asio for multiple udp connections? -
in application working on, hundreds of clients connect server via udp. socket connection remains open each client until client decides quit.
i downloaded boost's sample code asynchronous udp server @ http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tutorial/tutdaytime6/src.html.
from code, couple of things not clear:
as each connection made client, save ip of incoming client. however, code, not obvious can put logic.
it seems code can serve 1 client @ time. in case, there many concurrent connections , socket must kept alive each connection. how extend code? regards.
as each connection made client, save ip of incoming client. however, code, not obvious can put logic.
this code has no notion of connection. if you're writing code knows connection is, someplace decide whether or not each incoming datagram part of existing connection or establishing new one. that's put logic.
it seems code can serve 1 client @ time. in case, there many concurrent connections , socket must kept alive each connection.
you seem under impression udp socket associated connection. not so. udp knows nothing connections, that's entirely feature of code. since udp implementation has no idea these connections, give datagrams receives. there's no socket each connection there connection-oriented protocols tcp.
if need connections , reason still want use connectionless protocol udp, connection logic responsibility. have 1 socket , receive 1 datagram @ time, can sustain number of concurrent "connections" long write code support that.
Comments
Post a Comment