Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netdb.h>
- #include <stdio.h>
- #include <string.h>
- int main(int argc, char** argv) {
- struct addrinfo hints, *ai;
- int result;
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- result = getaddrinfo(argv[1], NULL, &hints, &ai);
- printf("Result %d %p\n", result, ai);
- if (result == 0 && ai != NULL) {
- printf("Canonname %s\n", ai->ai_canonname);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement