EBK COMPUTER SYSTEMS
EBK COMPUTER SYSTEMS
3rd Edition
ISBN: 8220101459107
Author: O'HALLARON
Publisher: YUZU
Question
Book Icon
Chapter 11.4, Problem 11.4PP
Program Plan Intro

IP addresses:

  • The IP address denotes an unsigned integer that is 32-bit.
  • The IP addresses is been stored by network programs in IP address structure.
  • The addresses present in IP address structure are stored in network byte order.
  •  An unsigned 32-bit integer is converted from host byte order to network byte order by “htonl” function.
  • An unsigned 32-bit integer is converted from network byte order host byte order by “ntohl” function.
  • The IP address is presented to humans in a form known as “dotted-decimal” notation.
    • Each byte is been represented by its corresponding decimal value and is separated by a period from other bytes.

The getaddrinfo Function:

  • It converts string representation of hostnames, host addresses, service names and port numbers into structures of socket address.
  • It denotes replacement for “gethostbyname” and “getservbyname” functions.
  • The two components of socket address denote “host” and “service”, the method returns result that points to a linked list of “addrinfo” structures.
  • The “host” argument can either be a domain name or a numeric address.
  • The “service” argument can be either a service name or a decimal port number.

The getnameinfo Function:

  • It converts structures of socket address to corresponding host and service name strings.
  • It denotes replacement for “gethostbyaddr” and “getservbyport” functions.
  • The argument “sa” points to a structure of socket address with size “salen” bytes.
  • It points to host with buffer of size “hostlen” bytes and “service” to a buffer of size “servlen” bytes.
  • The result is been copied into “host” and “service” buffers.
  • If it returns a non-zero error code, the application can convert it to a string by calling “gai_strerror”.

Blurred answer
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY