-
-
Notifications
You must be signed in to change notification settings - Fork 228
Open
Labels
Description
Once a UDP socket is connected in libuv, you have to call send with a null address or else you get UV_EISCONN and nothing is sent. There seems to be no way to do this through the uvw API, since the addr parameter is passed by reference. In udp.cc the wrappers are like:
UVW_INLINE void UDPHandle::send(const sockaddr &addr, std::unique_ptr<char[]> data, unsigned int len) {
...
req->send(get(), &addr);
}
Empirically it works to call it like
sock->send(*(sockaddr *)nullptr, txbuf, txbuf_size);
But this is undefined behavior in C++, and the compiler (at least Clang++-10) warns accordingly.
I think the right answer is to have versions of UDPHandle::send that don't take an address parameter.
References:
http://docs.libuv.org/en/v1.x/udp.html in the uv_udp_send section