Boost.Asio is throwing an error with a value of boost::asio::error::connection_refused
because the underlying socket's send*()
operation is returning an error code of ECONNREFUSED
. Per the udp manual page, send*()
functions are permitted to return ECONNREFUSED
:
All errors documented for socket or ip may be returned by a send or receive on a UDP socket.
ECONNREFUSED
No receiver was associated with the destination address. This might be caused by a previous packet sent over the socket.
While it can be odd to receive a connection related error on a connectionless protocol, the service is still permitted to return detected errors. The unreliable part of the protocol prevents the caller from receiving acknowledgement that the a message was received by the destination. However, this does not preclude the service from reporting a connection refused error if it knows the destination did not receive the message.