문제

I'm studying C and TCP/UDP. As the title... Is there any difference between inet_aton() and gethostbyname() in C? From what I know, both convert an IP address from a string to a number.

도움이 되었습니까?

해결책

gethostbyname() is obsolete. You should use getaddrinfo().

inet_aton() only works for IPv4.

Also, inet_aton() only convert a IPv4 notion (0.0.0.0) to int, getaddrinfo does DNS resolution.

다른 팁

gethostbyname() is used for getting ip-address from hostname and store them in struct in_addr.Where as inet_aton takes in the ip address in dotted format and converts into network byte order .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top