Implementing a synchronous UDP client
A synchronous UDP client is a part of a distributed application that complies with the following statements:
- Acts as a client in the client-server communication model
- Communicates with the server application using UDP protocol
- Uses I/O and control operations (at least those I/O operations that are related to communication with the server) that block the thread of execution until the corresponding operation completes, or an error occurs
A typical synchronous UDP client works according to the following algorithm:
- Obtain an IP-address and a protocol port number of each server the client application is intended to communicate with.
- Allocate a UDP socket.
- Exchange messages with the servers.
- Deallocate the socket.
This recipe demonstrates how to implement a synchronous UDP client application with Boost.Asio.
How to do it…
The following code sample demonstrates a possible implementation of a synchronous UDP client application with Boost.Asio. It is assumed that...