Getting and setting socket options

The socket's properties and its behavior can be configured by changing the values of its various options. When the socket object is instantiated, its options have default values. In many cases, the socket configured by default is a perfect fit, whereas in others, it may be needed to fine tune the socket by changing values of its options so that it meets the requirements of the application.

In this recipe, we will see how to get and set socket options with Boost.Asio.

Getting ready…

This recipe assumes familiarity with the content provided in Chapter 1, The Basics.

How to do it…

Each socket option, whose value can be set or obtained by means of a functionality provided by Boost.Asio, is represented by a separate class. ...

Get Boost.Asio C++ Network Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.