I am using boost::asio to make a socket network. The library has a number of different methods for sending and receiving data, each of which perform a similar task with a slight difference.
For sending data, boost provides the following functions:
boost::asio::basic_stream_socket::async_send()
boost::asio::basic_stream_socket::async_write_some()
boost::asio::basic_stream_socket::async_write()
And for receiving data, boost provides these functions:
boost::asio::basic_stream_socket::async_receive()
boost::asio::basic_stream_socket::async_read_some()
boost::asio::basic_stream_socket::async_read()
Out of these, which one(s) are the most appropriate to use for a game server, and why?
The
async_read()andasync_write()free functions are composed operations. They are implemented in terms of zero or more calls to the stream’sasync_read_some()orasync_write_some()methods.The member functions may not transmit or receive all data before the asynchronous operation completes. You should use the free functions if you desire that behavior.