It seems boost::asio defines a separate endpoint class for each protocol, which is irritating if you want to perform both UDP and TCP operations on a particular endpoint (have to convert from one to the other). I’d always just thought of an endpoint as an IP address (v4 or v6) and the port number, regardless of TCP or UDP.
Are there significant differences that justify separate classes? (i.e. couldn’t both tcp::socket and udp::socket accept something like ip::endpoint?)
The sockets are created differently
for TCP, and
for UDP.
I suspect that is the reason for the differing types in Boost.Asio. See
man 7 udporman 7 tcpfor more information, I’m assuming Linux since you didn’t tag your question.To solve your problem, extract the IP and port from a TCP endpoint and instantiate a UDP endpoint.
sample invocation: