Home | Libraries | People | FAQ | More |
This tutorial program shows how to use asio to implement a server application with UDP.
int main() { try { boost::asio::io_context io_context;
Create an ip::udp::socket object to receive requests on UDP port 13.
udp::socket socket(io_context, udp::endpoint(udp::v4(), 13));
Wait for a client to initiate contact with us. The remote_endpoint object will be populated by ip::udp::socket::receive_from().
Determine what we are going to send back to the client.
Send the response to the remote_endpoint.
Finally, handle any exceptions.
See the full source listing
Return to the tutorial index