<함수 prototype>
struct hostent *gethostbyname(const char *name);
int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
두 함수 모두 return type은 hostent struct 이다.
<struct hostent 구조 >
struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses */
==> 아래쪽에 in_addr구조체의 s_addr 변수 참조. 같은 형태임. 0xff01ffff의 네트웍바이트(순서대로) 형태(255.1.255.255)
} #define h_addr h_addr_list[0] /* for backward compatibility */ The members of the hostent structure are:
h_addrtype The type of address; always AF_INET or AF_INET6 at present. h_length The length of the address in bytes. h_addr_list An array of pointers to network addresses for the host (in net- HOST_NOT_FOUND The specified host is unknown. NO_ADDRESS or NO_DATA The requested name is valid but does not have an IP address. NO_RECOVERY A non-recoverable name server error occurred. TRY_AGAIN A temporary error occurred on an authoritative name server. Try again later.
<그 외 network관련 struct들 >
struct sockaddr_in { sa_family_t sin_family; /* address family: AF_INET */ in_port_t sin_port; /* port in network byte order */ struct in_addr sin_addr; /* internet address */ }; /* Internet address. */ struct in_addr { uint32_t s_addr; /* address in network byte order */ };0xffffffff의 네트웍바이트 형태.=255.255.255.255
<in_addr_t inet_addr(hostname) 함수> 이름을 0xffffffff (255.255.255.255 효과) 형태로 변환리턴.
리턴type: typedef uint32_t in_addr_t;
INADDR_NONE= -1 (255.255.255.255)을 리턴하는 경우. 약간문제가 될때도 있으나 거의 괜찮음.