Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP send after connect not possible #262

Open
tlbtlbtlb opened this issue Apr 6, 2022 · 1 comment
Open

UDP send after connect not possible #262

tlbtlbtlb opened this issue Apr 6, 2022 · 1 comment
Assignees

Comments

@tlbtlbtlb
Copy link

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

@skypjack skypjack self-assigned this Apr 6, 2022
@skypjack
Copy link
Owner

skypjack commented Apr 6, 2022

Sounds reasonable. We're working on a v3 branch that flips the project on its head. We'll add this function there probably. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants