Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

59. Sockets: Internet Domains > Protocol-Independent Host and Service Conversio...

Protocol-Independent Host and Service Conversion

The getaddrinfo() function converts host and service names to IP addresses and port numbers. It was defined in POSIX.1g as the (reentrant) successor to the obsolete gethostbyname() and getservbyname() functions. (Replacing the use of gethostbyname() with getaddrinfo() allows us to eliminate IPv4-versus-IPv6 dependencies from our programs.)

The getnameinfo() function is the converse of getaddrinfo(). It translates a socket address structure (either IPv4 or IPv6) to strings containing the corresponding host and service name. This function is the (reentrant) equivalent of the obsolete gethostbyaddr() and getservbyport() functions.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint