I was strange, in the Win32 project to import the # include <WS2tcpip.h> after the use of the Inet_ntop () function without pressure, but in the DLL project error: Intellisense:identifier "inet_ Ntop "is undefined, really do not understand, have a friend can tell me ah. It's urgent to use it, only with your own function.
Inet_ntop (): Converts an IPV4 or IPV6 Internet network address to a string in Internet standard format.
const char *inet_ntop (int af, const void *SRC, char *dst, socklen_t cnt) { if (af = = af_inet) { struct sockaddr _in in; memset (&in, 0, sizeof (in)); in.sin_family = af_inet; memcpy (&in.sin_addr, SRC, sizeof (struct in_addr)); Getnameinfo (struct sockaddr *) &in, sizeof (struct sockaddr_in), DST, CNT, NULL, 0, ni_numerichost); return DST; } else if (AF = = Af_inet6) { struct sockaddr_in6 in; memset (&in, 0, sizeof (in)); in.sin6_family = Af_inet6; memcpy (&in.sin6_addr, SRC, sizeof (struct IN_ADDR6)); Getnameinfo (struct sockaddr *) &in, sizeof (struct sockaddr_in6), DST, CNT, NULL, 0, ni_numerichost); return DST; } return NULL;}
Inet_pton (): Converts an IPV4 or IPv6 Internet Network address on its standard text presentation form into its numeric Bina Ry form.
int Inet_pton (int af, const char *src, void *dst) { struct addrinfo hints, *res, *ressave; memset (&hints, 0, sizeof (struct addrinfo)); hints.ai_family = AF; if (getaddrinfo (SRC, NULL, &hints, &res)! = 0) {//commented out because Dolog and Log_err is not defined.../ / Dolog (Log_err, "couldn ' t resolve host%s\n", SRC); return-1; } Ressave = res; while (res) { memcpy (DST, res->ai_addr, Res->ai_addrlen); res = res->ai_next; } Freeaddrinfo (ressave); return 0;}
Not to be continued!
DNS IPV6--inet_ntop, Inet_pton