Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/socket.h>
  3. #include <netdb.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. int main(int argc, char** argv) {
  8. struct addrinfo hints, *ai;
  9. int result;
  10. memset(&hints, 0, sizeof(hints));
  11. hints.ai_flags = AI_CANONNAME;
  12. hints.ai_family = PF_UNSPEC;
  13. hints.ai_socktype = SOCK_STREAM;
  14. hints.ai_protocol = IPPROTO_TCP;
  15. result = getaddrinfo(argv[1], NULL, &hints, &ai);
  16. printf("Result %d %p\n", result, ai);
  17. if (result == 0 && ai != NULL) {
  18. printf("Canonname %s\n", ai->ai_canonname);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement