projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
maint: update copyright
[gnulib.git]
/
lib
/
sendto.c
diff --git
a/lib/sendto.c
b/lib/sendto.c
index
51704de
..
6a8fad2
100644
(file)
--- a/
lib/sendto.c
+++ b/
lib/sendto.c
@@
-1,6
+1,6
@@
/* sendto.c --- wrappers for Windows sendto function
/* sendto.c --- wrappers for Windows sendto function
- Copyright (C) 2008-201
0
Free Software Foundation, Inc.
+ Copyright (C) 2008-201
4
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-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);
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;
+ }
}
}