1 #ifndef WIN32_LEAN_AND_MEAN 2 #define WIN32_LEAN_AND_MEAN 3 #endif 4 #undef __CRT__NO_INLINE 5 #define __CRT__NO_INLINE 6 #include <winsock2.h> 7 #include <wspiapi.h> 8 9 int WINAPI WspiapiClone(WORD wPort,struct addrinfo * ptResult)10WspiapiClone (WORD wPort, struct addrinfo *ptResult) 11 { 12 struct addrinfo *p = NULL; 13 struct addrinfo *n = NULL; 14 15 for (p = ptResult; p != NULL;) 16 { 17 n = WspiapiNewAddrInfo (SOCK_DGRAM, p->ai_protocol, wPort, 18 ((struct sockaddr_in *) p->ai_addr)->sin_addr.s_addr); 19 if (!n) 20 break; 21 n->ai_next = p->ai_next; 22 p->ai_next = n; 23 p = n->ai_next; 24 } 25 if (p != NULL) 26 return EAI_MEMORY; 27 return 0; 28 } 29