Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

uv_udp_start_recv callback with nread = 0 #1349

Closed
txdv opened this issue Jul 2, 2014 · 4 comments
Closed

uv_udp_start_recv callback with nread = 0 #1349

txdv opened this issue Jul 2, 2014 · 4 comments

Comments

@txdv
Copy link
Contributor

txdv commented Jul 2, 2014

UDP packets can be sent with 0 content.
The content of the UDP packet is literally nothing, we are just sending the udp header.

Now look at the callback:

typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, ssize_t nread,  const uv_buf_t* buf, const struct sockaddr* addr, unsigned flags);

In the case of an empty udp packets we have nread == 0 and addr != NULL

When the udp handle is closed it also issues a callback with nread == 0 and addr == NULL.

This is bad API design. Users of libuv will forget to check for addr. It is already a bug in nodejs. You can't currently receive empty udp packets.

I propose to drop the callback with 0 on socket closing. Maybe add another callback in the fields.

@saghul
Copy link
Contributor

saghul commented Jul 2, 2014

Thanks for the report Andrius, will investigate.

@txdv
Copy link
Contributor Author

txdv commented Jul 2, 2014

At least it should be documented...

@txdv
Copy link
Contributor Author

txdv commented Jul 2, 2014

#1350

here is the pull request for documentation

@saghul
Copy link
Contributor

saghul commented Jul 2, 2014

For completeness, it's like this by design. #1350 landed enhancing documentation, thanks!

@saghul saghul closed this as completed Jul 2, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants