66 WSAPROTOCOL_INFOW
info;
69 if (
handle->socket != INVALID_SOCKET)
74 return WSAGetLastError();
78 if (!SetHandleInformation((
HANDLE)
socket, HANDLE_FLAG_INHERIT, 0)) {
79 return GetLastError();
88 return GetLastError();
100 return GetLastError();
103 if (
info.ProtocolChain.ChainLen == 1) {
104 if (SetFileCompletionNotificationModes(
111 }
else if (GetLastError() != ERROR_INVALID_FUNCTION) {
112 return GetLastError();
133 handle->socket = INVALID_SOCKET;
136 handle->func_wsarecv = WSARecv;
137 handle->func_wsarecvfrom = WSARecvFrom;
138 handle->send_queue_size = 0;
139 handle->send_queue_count = 0;
152 if (sock == INVALID_SOCKET) {
153 err = WSAGetLastError();
172 closesocket(
handle->socket);
173 handle->socket = INVALID_SOCKET;
177 if (
handle->reqs_pending == 0) {
185 handle->reqs_pending == 0) {
200 unsigned int flags) {
210 return ERROR_INVALID_PARAMETER;
213 if (
handle->socket == INVALID_SOCKET) {
215 if (sock == INVALID_SOCKET) {
216 return WSAGetLastError();
229 if (setsockopt(
handle->socket,
233 sizeof yes) == SOCKET_ERROR) {
234 err = WSAGetLastError();
249 setsockopt(
handle->socket,
257 if (
r == SOCKET_ERROR) {
258 return WSAGetLastError();
277 memset(&
req->u.io.overlapped, 0,
sizeof(
req->u.io.overlapped));
306 &
req->u.io.overlapped,
312 req->u.io.overlapped.InternalHigh =
bytes;
338 &
req->u.io.overlapped,
344 req->u.io.overlapped.InternalHigh =
bytes;
379 loop->active_udp_streams++;
381 handle->recv_cb = recv_cb;
382 handle->alloc_cb = alloc_cb;
396 handle->loop->active_udp_streams--;
417 memset(&
req->u.io.overlapped, 0,
sizeof(
req->u.io.overlapped));
419 result = WSASendTo(
handle->socket,
426 &
req->u.io.overlapped,
431 req->u.io.queued_bytes = 0;
433 handle->send_queue_size +=
req->u.io.queued_bytes;
434 handle->send_queue_count++;
441 handle->send_queue_size +=
req->u.io.queued_bytes;
442 handle->send_queue_count++;
446 return WSAGetLastError();
464 if (
err == WSAEMSGSIZE) {
467 }
else if (
err == WSAECONNRESET ||
err == WSAENETRESET) {
492 req->u.io.overlapped.InternalHigh,
498 struct sockaddr_storage
from;
512 from_len =
sizeof from;
516 if (WSARecvFrom(
handle->socket,
524 NULL) != SOCKET_ERROR) {
529 err = WSAGetLastError();
530 if (
err == WSAEMSGSIZE) {
537 }
else if (
err == WSAEWOULDBLOCK) {
540 }
else if (
err == WSAECONNRESET ||
err == WSAENETRESET) {
572 handle->send_queue_size -=
req->u.io.queued_bytes;
573 handle->send_queue_count--;
591 const char* interface_addr,
608 memset(&mreq, 0,
sizeof mreq);
610 if (interface_addr) {
615 mreq.imr_interface.s_addr = htonl(INADDR_ANY);
620 switch (membership) {
622 optname = IP_ADD_MEMBERSHIP;
625 optname = IP_DROP_MEMBERSHIP;
631 if (setsockopt(
handle->socket,
635 sizeof mreq) == SOCKET_ERROR) {
645 const char* interface_addr,
649 struct ipv6_mreq mreq;
663 memset(&mreq, 0,
sizeof(mreq));
665 if (interface_addr) {
670 mreq.ipv6mr_interface = 0;
673 mreq.ipv6mr_multiaddr = multicast_addr->
sin6_addr;
675 switch (membership) {
677 optname = IPV6_ADD_MEMBERSHIP;
680 optname = IPV6_DROP_MEMBERSHIP;
686 if (setsockopt(
handle->socket,
690 sizeof mreq) == SOCKET_ERROR) {
700 const char* interface_addr,
703 struct ip_mreq_source mreq;
718 memset(&mreq, 0,
sizeof(mreq));
720 if (interface_addr !=
NULL) {
725 mreq.imr_interface.s_addr = htonl(INADDR_ANY);
732 optname = IP_ADD_SOURCE_MEMBERSHIP;
734 optname = IP_DROP_SOURCE_MEMBERSHIP;
738 if (setsockopt(
handle->socket,
742 sizeof(mreq)) == SOCKET_ERROR) {
752 const char* interface_addr,
755 struct group_source_req mreq;
760 STATIC_ASSERT(
sizeof(mreq.gsr_group) >=
sizeof(*multicast_addr));
761 STATIC_ASSERT(
sizeof(mreq.gsr_source) >=
sizeof(*source_addr));
774 memset(&mreq, 0,
sizeof(mreq));
776 if (interface_addr !=
NULL) {
782 mreq.gsr_interface = 0;
785 memcpy(&mreq.gsr_group, multicast_addr,
sizeof(*multicast_addr));
786 memcpy(&mreq.gsr_source, source_addr,
sizeof(*source_addr));
795 if (setsockopt(
handle->socket,
799 sizeof(mreq)) == SOCKET_ERROR) {
808 const char* multicast_addr,
809 const char* interface_addr,
816 else if (
uv_ip6_addr(multicast_addr, 0, &addr6) == 0)
824 const char* multicast_addr,
825 const char* interface_addr,
826 const char* source_addr,
829 struct sockaddr_storage mcast_addr;
832 struct sockaddr_storage src_addr;
868 struct sockaddr_storage addr_st;
875 if (!interface_addr) {
876 memset(&addr_st, 0,
sizeof addr_st);
884 }
else if (
uv_ip4_addr(interface_addr, 0, addr4) == 0) {
886 }
else if (
uv_ip6_addr(interface_addr, 0, addr6) == 0) {
892 if (
handle->socket == INVALID_SOCKET)
895 if (addr_st.ss_family ==
AF_INET) {
896 if (setsockopt(
handle->socket,
900 sizeof(addr4->
sin_addr)) == SOCKET_ERROR) {
903 }
else if (addr_st.ss_family ==
AF_INET6) {
904 if (setsockopt(
handle->socket,
912 assert(0 &&
"unexpected address family");
921 BOOL optval = (BOOL)
value;
923 if (
handle->socket == INVALID_SOCKET)
926 if (setsockopt(
handle->socket,
939 struct sockaddr_storage
addr;
951 WSAPROTOCOL_INFOW protocol_info;
956 opt_len = (
int)
sizeof protocol_info;
960 (
char*) &protocol_info,
961 &opt_len) == SOCKET_ERROR) {
968 protocol_info.iAddressFamily);
982 #define SOCKOPT_SETTER(name, option4, option6, validate) \
983 int uv_udp_set_##name(uv_udp_t* handle, int value) { \
984 DWORD optval = (DWORD) value; \
986 if (!(validate(value))) { \
990 if (handle->socket == INVALID_SOCKET) \
993 if (!(handle->flags & UV_HANDLE_IPV6)) { \
995 if (setsockopt(handle->socket, \
1000 return uv_translate_sys_error(WSAGetLastError()); \
1004 if (setsockopt(handle->socket, \
1009 return uv_translate_sys_error(WSAGetLastError()); \
1015 #define VALIDATE_TTL(value) ((value) >= 1 && (value) <= 255)
1016 #define VALIDATE_MULTICAST_TTL(value) ((value) >= -1 && (value) <= 255)
1017 #define VALIDATE_MULTICAST_LOOP(value) (1)
1025 IPV6_MULTICAST_HOPS,
1029 IPV6_MULTICAST_LOOP,
1032 #undef SOCKOPT_SETTER
1034 #undef VALIDATE_MULTICAST_TTL
1035 #undef VALIDATE_MULTICAST_LOOP
1044 unsigned int flags) {
1140 struct sockaddr_storage converted;
1152 if (
handle->send_queue_count != 0)
1172 (
const struct sockaddr*) &converted,
static mcore_handle handle
RzBinInfo * info(RzBinFile *bf)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd domain
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd socket
#define DECREASE_ACTIVE_COUNT(loop, handle)
static INLINE void uv_want_endgame(uv_loop_t *loop, uv_handle_t *handle)
#define INCREASE_ACTIVE_COUNT(loop, handle)
#define uv__handle_close(handle)
#define DECREASE_PENDING_REQ_COUNT(handle)
#define uv__handle_closing(handle)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset void static length char static len const struct iovec static count unsigned long static filedes static sched_yield static flags static oldfd static pause unsigned static seconds static protocol struct sockaddr addrlen
assert(limit<=UINT32_MAX/2)
static INLINE void uv_insert_pending_req(uv_loop_t *loop, uv_req_t *req)
#define GET_REQ_SOCK_ERROR(req)
#define UNREGISTER_HANDLE_REQ(loop, handle, req)
#define UV_SUCCEEDED_WITH_IOCP(result)
#define REGISTER_HANDLE_REQ(loop, handle, req)
#define UV_SUCCEEDED_WITHOUT_IOCP(result)
#define SET_REQ_ERROR(req, error)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void flags
struct in6_addr sin6_addr
int uv__getsockpeername(const uv_handle_t *handle, uv__peersockfunc func, struct sockaddr *name, int *namelen)
struct sockaddr_in uv_addr_ip4_any_
int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF *buffers, DWORD buffer_count, DWORD *bytes, DWORD *flags, WSAOVERLAPPED *overlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine)
int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF *buffers, DWORD buffer_count, DWORD *bytes, DWORD *flags, struct sockaddr *addr, int *addr_len, WSAOVERLAPPED *overlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine)
struct sockaddr_in6 uv_addr_ip6_any_
static char bufs[4][128]
Buffers for uint64_to_str() and uint64_to_nicestr()
int uv_udp_set_source_membership(uv_udp_t *handle, const char *multicast_addr, const char *interface_addr, const char *source_addr, uv_membership membership)
int uv__udp_init_ex(uv_loop_t *loop, uv_udp_t *handle, unsigned flags, int domain)
int uv__udp_send(uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen, uv_udp_send_cb send_cb)
int uv_udp_set_broadcast(uv_udp_t *handle, int on)
int uv__udp_recv_start(uv_udp_t *handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
int uv__udp_disconnect(uv_udp_t *handle)
int uv__udp_connect(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen)
int uv_udp_using_recvmmsg(const uv_udp_t *handle)
int uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock)
int uv__udp_recv_stop(uv_udp_t *handle)
int uv_udp_set_multicast_interface(uv_udp_t *handle, const char *interface_addr)
int uv__udp_try_send(uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen)
int uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, int *namelen)
int uv__udp_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
int uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name, int *namelen)
int uv_udp_set_membership(uv_udp_t *handle, const char *multicast_addr, const char *interface_addr, uv_membership membership)
int uv__udp_is_connected(uv_udp_t *handle)
size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs)
@ UV_HANDLE_UDP_CONNECTED
@ UV_HANDLE_SYNC_BYPASS_IOCP
#define UV_REQ_INIT(req, typ)
#define uv__handle_init(loop_, h, type_)
#define STATIC_ASSERT(expr)
UV_EXTERN int uv_ip4_addr(const char *ip, int port, struct sockaddr_in *addr)
UV_EXTERN int uv_translate_sys_error(int sys_errno)
UV_EXTERN int uv_ip6_addr(const char *ip, int port, struct sockaddr_in6 *addr)
UV_EXTERN uv_buf_t uv_buf_init(char *base, unsigned int len)
UV_EXTERN int uv_udp_recv_stop(uv_udp_t *handle)
void(* uv_udp_recv_cb)(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags)
void(* uv_udp_send_cb)(uv_udp_send_t *req, int status)
void(* uv_alloc_cb)(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
UV_EXTERN int uv_inet_pton(int af, const char *src, void *dst)
int uv__udp_set_source_membership6(uv_udp_t *handle, const struct sockaddr_in6 *multicast_addr, const char *interface_addr, const struct sockaddr_in6 *source_addr, uv_membership membership)
const unsigned int uv_active_udp_streams_threshold
#define SOCKOPT_SETTER(name, option4, option6, validate)
static void uv_udp_queue_recv(uv_loop_t *loop, uv_udp_t *handle)
static int uv__udp_set_membership4(uv_udp_t *handle, const struct sockaddr_in *multicast_addr, const char *interface_addr, uv_membership membership)
int uv__udp_set_membership6(uv_udp_t *handle, const struct sockaddr_in6 *multicast_addr, const char *interface_addr, uv_membership membership)
void uv_udp_close(uv_loop_t *loop, uv_udp_t *handle)
void uv_process_udp_recv_req(uv_loop_t *loop, uv_udp_t *handle, uv_req_t *req)
void uv_udp_endgame(uv_loop_t *loop, uv_udp_t *handle)
int uv__udp_is_bound(uv_udp_t *handle)
static int uv_udp_set_socket(uv_loop_t *loop, uv_udp_t *handle, SOCKET socket, int family)
static int uv__udp_set_source_membership4(uv_udp_t *handle, const struct sockaddr_in *multicast_addr, const char *interface_addr, const struct sockaddr_in *source_addr, uv_membership membership)
void uv_process_udp_send_req(uv_loop_t *loop, uv_udp_t *handle, uv_udp_send_t *req)
#define VALIDATE_MULTICAST_LOOP(value)
#define VALIDATE_MULTICAST_TTL(value)
static int uv_udp_maybe_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
static int uv__send(uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen, uv_udp_send_cb cb)
#define VALIDATE_TTL(value)
#define FILE_SKIP_SET_EVENT_ON_HANDLE
#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS
int uv__convert_to_localhost_if_unspecified(const struct sockaddr *addr, struct sockaddr_storage *storage)
#define MCAST_LEAVE_SOURCE_GROUP
#define MCAST_JOIN_SOURCE_GROUP