Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
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
Students have asked these similar questions
Write a C/C++ code to Implement the following scenario: An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to distribute these addresses to three groups of customers as follows: a. The first group has 64 customers; each needs 256 addresses. b. The second group has 128 customers; each needs 128 addresses. c. The third group has 128 customers; each needs 64 addresses. Design and Implement the sub blocks and find out how many addresses are still available after these allocations.
4.19.16: [5] <COD §4.6>. In this exercise, we examine how pipelining affects the clock cycle time of the processor. Problems in this exercise assume that individual stages of the datapath have the following latencies:   Also, assume that instructions executed by the processor are broken down as follows: (a) What is the clock cycle time in a pipelined and non-pipelined processor? (b) What is the total latency of an lw instruction in a pipelined and non-pipelined processor? (c) If we can split one stage of the pipelined datapath into two new stages, each with half the latency of the original stage, which stage would you split and what is the new clock cycle time of the processor? (d) Assuming there are no stalls or hazards, what is the utilization of the data memory? (e) Assuming there are no stalls or hazards, what is the utilization of the write-register port of the "Registers" unit?    No hand written and fast answer with explanation
4.18 [5] <COD §4.5> Assume that X1 is initialized to 11 and X2 is initialized to 22. Suppose you executed the code below on a version of the pipeline from COD Section 4.5 (An overview of pipelining) that does not handle data hazards (i.e., the programmer is responsible for addressing data hazards by inserting NOP instructions where necessary). What would the final values of registers X3 and X4 be? ADDI X1, X2, #5   ADD X3, X1, X2   ADDI X4, X1, #15
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr