Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10. Refer to the code snippet below and answer the following questions a) To wha

ID: 3728743 • Letter: 1

Question

10. Refer to the code snippet below and answer the following questions a) To what host IP address and what port the program attempts to connect? What line(s) in the code contain this infor mation? (b) What transport protocol is used? What line(s) in the code indicate this? (c) ls there any checking performed in this snippet (including underlying transport and network protocols) to ensure that the other end has accepted the connection and is receiving data? Explain why (d) How many packets are exchanged between the computer running the program and the re- mote host if the function call near the end of the snippet (send(sfd, data, len, 0)) is successful? memsets&hints; 0, sizeoff struct ad drinfo hints. aifamilyAF INET; hints ai socktype - SOCKDGRAM; hints ai protocolPPROTO UDP; s getaddrinfo"at5030-eng245 3server lakeheadu ca", "40233" 4. &hints;, &result; 71 if(s!_ 0) { fprintf(stderr, "getaddrinfo :-%s ", gai-strerror(s)); exit (EXIT FAILURE) -socket(result fprintf(stderr, "Failed-to-create. Socket " 10 sfd al-fa m ily, resultai-socktype, resultal-protocol): 12 f (sfd_-1) 13 14 exit (EXIT FAILURE) 16 17 18 19 20 21 messageAAAAAAaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" lenstrlen (message) 1 /* 1 for terminating null byte / for {i-0: i

Explanation / Answer

(a)

The program attempts to connect to "at5030-eng2453server.lakeheadu.ca" at port number "402533"

This information is present at line number 5-6.

The getaddrinfo() function is defined for protocol-independent nodename-to-address translation.

(b)

The transport layer protocol used here is UDP ( USER DATAGRAM PROTOCOL )

This information is present at line number 3-4.

(c)

The first error checking is performed at line number, 12 - 15, to make sure that

sockets exists and we are able to connect ( connection accepted successfully ) it.

Socket system call returns -1 in case of faliure.

The second error checking is performed at line number, 20 - 23, to make sure that

the packet is sent is sent successfully.( data received ).

(d)

The length is message is less than the size udp packet can send so complete message is send in one go.

But we are looping three time so three packets will be send of same message.

This information is present at line number 18.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote