Summary

There are three basic steps when it comes to developing a network application. The first step includes establishing a connection between the source and target, which means the client and server. We can configure the socket object along with the acceptor object to establish the connection.

Secondly, we exchange data by reading and writing to the socket. For this purpose, we can use the basic_stream_socket functions collection. In our previous example, we used the boost::asio::async_write() method to send the data and the boost::asio::async_read() method to receive the data. Finally, the last step is releasing the connection. By using the shutdown() method in the ip::tcp::socket object, we can disable the sending and receiving of data on the socket. Then, invoking the close() method after the shutdown() function will close the socket and free up the handler. We also have already created a wrapper for all functions, which is most frequently used in network application programming by accessing the Boost.Asio library. This means we can develop a network application simply and efficiently since we do not need to reuse code over and over again.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset