/ Published in: C
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
int status; struct addrinfo hints; struct addrinfo *servinfo; // will point to the results hints.ai_family = AF_UNSPEC; // don't care IPv4 or IPv6 hints.ai_socktype = SOCK_STREAM; // TCP stream sockets hints.ai_flags = AI_PASSIVE; // fill in my IP for me if ((status = getaddrinfo(NULL, "3490", &hints, &servinfo)) != 0) { } // servinfo now points to a linked list of 1 or more struct addrinfos // ... do everything until you don't need servinfo anymore .... freeaddrinfo(servinfo); // free the linked-list