diff options
Diffstat (limited to 'lib/sendto.c')
-rw-r--r-- | lib/sendto.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/sendto.c b/lib/sendto.c index fb2231336..b709299a7 100644 --- a/lib/sendto.c +++ b/lib/sendto.c @@ -33,9 +33,18 @@ rpl_sendto (int fd, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) { SOCKET sock = FD_TO_SOCKET (fd); - int r = sendto (sock, buf, len, flags, to, tolen); - if (r < 0) - set_winsock_errno (); - return r; + if (sock == INVALID_SOCKET) + { + errno = EBADF; + return -1; + } + else + { + int r = sendto (sock, buf, len, flags, to, tolen); + if (r < 0) + set_winsock_errno (); + + return r; + } } |