static void uv__getaddrinfo_work(struct uv__work* w) { uv_getaddrinfo_t* req; int err; req = container_of(w, uv_getaddrinfo_t, work_req); err = GetAddrInfoW(req->node, req->service, req->hints, &req->res); req->retcode = uv__getaddrinfo_translate_error(err); }
static void uv__getaddrinfo_work(struct uv__work* w) { uv_getaddrinfo_t* req; int err; req = container_of(w, uv_getaddrinfo_t, work_req); #if defined(__NUTTX__) err = 0; #else /* Only IPv4 is supported now. (Not support IPv6.)*/ if (req->hints) { req->hints->ai_family = AF_INET; } err = getaddrinfo(req->hostname, req->service, req->hints, &req->addrinfo); #endif req->retcode = uv__getaddrinfo_translate_error(err); }
static void uv__getnameinfo_work(struct uv__work* w) { uv_getnameinfo_t* req; WCHAR host[NI_MAXHOST]; WCHAR service[NI_MAXSERV]; int ret; req = container_of(w, uv_getnameinfo_t, work_req); if (GetNameInfoW((struct sockaddr*)&req->storage, sizeof(req->storage), host, ARRAY_SIZE(host), service, ARRAY_SIZE(service), req->flags)) { ret = WSAGetLastError(); req->retcode = uv__getaddrinfo_translate_error(ret); return; } ret = WideCharToMultiByte(CP_UTF8, 0, host, -1, req->host, sizeof(req->host), NULL, NULL); if (ret == 0) { req->retcode = uv_translate_sys_error(GetLastError()); return; } ret = WideCharToMultiByte(CP_UTF8, 0, service, -1, req->service, sizeof(req->service), NULL, NULL); if (ret == 0) { req->retcode = uv_translate_sys_error(GetLastError()); } }
/* getnameinfo worker thread implementation */ static DWORD WINAPI getnameinfo_thread_proc(void* parameter) { uv_getnameinfo_t* req = (uv_getnameinfo_t*)parameter; uv_loop_t* loop = req->loop; WCHAR host[NI_MAXHOST]; WCHAR service[NI_MAXSERV]; int ret = 0; assert(req != NULL); ret = GetNameInfoW((struct sockaddr*)&req->storage, sizeof(req->storage), host, sizeof(host), service, sizeof(service), req->flags); req->retcode = uv__getaddrinfo_translate_error(ret); /* convert results to UTF-8 */ WideCharToMultiByte(CP_UTF8, 0, host, -1, req->host, sizeof(req->host), NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, service, -1, req->service, sizeof(req->service), NULL, NULL); /* post getnameinfo completed */ POST_COMPLETION_FOR_REQ(loop, req); return 0; }