D
D
DenisVladimirovich2017-04-23 02:52:19
linux
DenisVladimirovich, 2017-04-23 02:52:19

How to run handler for UDP connection?

So. To the point. Tell. Created a simple server for one client via UDP protocol. When writing a server for a large number of clients, I ran into such a problem, namely how to handle each client. In Java, so to speak, a channel was created in netty. Is there something similar in C++?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dummyman, 2017-04-23
@dummyman

In general, servers usually write in C.
But if the pluses are closer to you, Boost solves all such issues. More specifically, Boost.Asio might suit you .

D
Dmitry, 2017-04-23
@TrueBers

Well, so, and you read about the difference between UDP and TCP and everything will become clear.
UDP has no concept of connection or byte stream. There are concepts of datagrams . These are atomic entities that are received in exactly the same way as they are sent, in exactly the same form.
Channels in Java are created simply for unification, for some kind of pseudo-streaming for convenient processing. In fact, there is no channel and no flow. There are individual datagrams of a certain size that you must accept.
Each client is identified by its address:port pair from which the data came via the recvfrom. There are no other options.
This is if synchronous processing is needed. For the asynchronous option, as dummyman already answered, it's more convenient to use Asio.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question