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.
Question
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.
Solution
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.
OTHER TIPS
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 .