On Fri, Aug 2, 2019 at 4:01 PM Iñaki Baz Castillo <i...@aliax.net> wrote:
>
> > void (*uv_udp_recv_cb)(uv_udp_t* handle, ssize_t nread, const uv_buf_t* 
> > buf, const struct sockaddr* addr, unsigned flags)
> >
> > nread: Number of bytes that have been received. 0 if there is no more data 
> > to read. You may discard or repurpose the read buffer. Note that 0 may also 
> > mean that an empty datagram was received (in this case addr is not NULL). < 
> > 0 if a transmission error was detected.
>
>
> So, if nread is < 0 it must be considered an error. However, ssize_t
> can just be -1 or 0 or a positive value. So, if read operation failed,
> nread will always be -1. Is that true?
>
> And, if so, does it make sense to do this?
>
>   printf("UV UDP read error: %s", uv_strerror(nread));
>
> Thanks.

When nread < 0, it's one of the UV_E* status codes. Those are always < 0.

-1 corresponds to UV_EPERM on most platforms.

If your assumption is that because the type is ssize_t it can only be
>= -1, that's mistaken. Hope that helps!

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to libuv+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/libuv/CAHQurc8_sPfGVZDQF%2B_YQcKaoHf2AEXzGEkEraN127mCXr0u9g%40mail.gmail.com.

Reply via email to