Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. char* GetIpByHost(char* host_name){
  2.  
  3. struct hostent *he;
  4. struct in_addr **addr_list;
  5. static char ip[100];
  6. int i;
  7.  
  8. he = gethostbyname(host_name);
  9. addr_list = (struct in_addr **)he->h_addr_list;
  10.  
  11. for(i = 0; addr_list[i] != NULL; i++)
  12. strcpy(ip, inet_ntoa(*addr_list[i]));
  13.  
  14. return ip;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement