0
votes

Why does socket_base not have a send() method? Basically, I would like to use boost::asio's sockets like linux socket descriptors: whether the underlying socket is UDP or TCP it doesn't matter, you can call read(), write(), sendto(), etc... on them.

Is there a more proper solution than just writing a wrapper class around asio's udp & tcp socket classes?

1

1 Answers

2
votes

You need to use a particular type of socket, like boost::asio::ip::tcp::socket, which is a stream-based TCP socket, or boost::asio::ip::udp::socket, which is for datagrams. The socket_base class is simply a base class which stores common functionality. The actual socket classes contain all the transfer functions you're looking for, like send and receive functions.

As you can see in the documentation, each socket type has send and receive functions.