summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibuv/src/win/udp.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-22 15:18:39 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-01-22 15:18:44 (GMT)
commit63f263b27fa9b9c63f038ff108118726bc9c5c64 (patch)
tree7022b7804d75353ed9d32570dff17b8ffe71feaf /Utilities/cmlibuv/src/win/udp.c
parentc81ace7ab7e5e325fef9339ed3ea05abbd0f8be4 (diff)
parent6db7b35236b81a73047a47c0f70f8befbf2ca51f (diff)
downloadCMake-63f263b27fa9b9c63f038ff108118726bc9c5c64.zip
CMake-63f263b27fa9b9c63f038ff108118726bc9c5c64.tar.gz
CMake-63f263b27fa9b9c63f038ff108118726bc9c5c64.tar.bz2
Merge topic 'update-libuv'
6db7b352 libuv: Update build within CMake b58d48c1 Merge branch 'upstream-libuv' into update-libuv f4a26c74 libuv 2018-01-19 (63de1eca) e8b57c22 libuv: Teach import script to add missing newlines Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1666
Diffstat (limited to 'Utilities/cmlibuv/src/win/udp.c')
-rw-r--r--Utilities/cmlibuv/src/win/udp.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/Utilities/cmlibuv/src/win/udp.c b/Utilities/cmlibuv/src/win/udp.c
index 2fd15cf..cd1d0e0 100644
--- a/Utilities/cmlibuv/src/win/udp.c
+++ b/Utilities/cmlibuv/src/win/udp.c
@@ -897,13 +897,12 @@ int uv__udp_send(uv_udp_send_t* req,
int err;
if (!(handle->flags & UV_HANDLE_BOUND)) {
- if (addrlen == sizeof(uv_addr_ip4_any_)) {
+ if (addrlen == sizeof(uv_addr_ip4_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
- } else if (addrlen == sizeof(uv_addr_ip6_any_)) {
+ else if (addrlen == sizeof(uv_addr_ip6_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
- } else {
- abort();
- }
+ else
+ return UV_EINVAL;
err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
if (err)
return uv_translate_sys_error(err);
@@ -922,5 +921,45 @@ int uv__udp_try_send(uv_udp_t* handle,
unsigned int nbufs,
const struct sockaddr* addr,
unsigned int addrlen) {
- return UV_ENOSYS;
+ DWORD bytes;
+ const struct sockaddr* bind_addr;
+ struct sockaddr_storage converted;
+ int err;
+
+ assert(nbufs > 0);
+
+ err = uv__convert_to_localhost_if_unspecified(addr, &converted);
+ if (err)
+ return err;
+
+ /* Already sending a message.*/
+ if (handle->send_queue_count != 0)
+ return UV_EAGAIN;
+
+ if (!(handle->flags & UV_HANDLE_BOUND)) {
+ if (addrlen == sizeof(uv_addr_ip4_any_))
+ bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
+ else if (addrlen == sizeof(uv_addr_ip6_any_))
+ bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
+ else
+ return UV_EINVAL;
+ err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
+ if (err)
+ return uv_translate_sys_error(err);
+ }
+
+ err = WSASendTo(handle->socket,
+ (WSABUF*)bufs,
+ nbufs,
+ &bytes,
+ 0,
+ (const struct sockaddr*) &converted,
+ addrlen,
+ NULL,
+ NULL);
+
+ if (err)
+ return uv_translate_sys_error(WSAGetLastError());
+
+ return bytes;
}