X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fsendto.c;h=ab575f4d28c208565ff883a7010664f70f41adca;hb=86627bb14a123f183bd094e582e4cd9f2aca489a;hp=b6cb8b9602e1608c3b517926b12a9cad0fe1f0e2;hpb=441aa3044f43e5572f58c354f01e6bc070acd5c7;p=gnulib.git diff --git a/lib/sendto.c b/lib/sendto.c index b6cb8b960..ab575f4d2 100644 --- a/lib/sendto.c +++ b/lib/sendto.c @@ -1,6 +1,6 @@ /* sendto.c --- wrappers for Windows sendto function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2012 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 @@ -28,14 +28,23 @@ #undef sendto -int -rpl_sendto (int fd, const void *buf, int len, int flags, - struct sockaddr *to, int tolen) +ssize_t +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; + } }