Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the code above, to get responses from the server, the TCP client program should register for a source port number, but in the program,

image text in transcribed
Given the code above, to get responses from the server, the TCP client program should register for a source port number, but in the program, this step seems to be missing. Without this port number, how can the client program get responses? (2) Which line of the code triggers the three-way handshake protocol? (3) There are two write() calls in this client program, will each call trigger a separate TCP packet? 
#include #include #include include int main () // Step 1: Create a socket int sockfd socket (AF_INET, SOCK_STREAM, 0) // Step 2: Set the destination information struct sockaddr_in dest; memset (&dest, 0, sizeof (struct sockaddr_in)); dest. sin-family AF_INET; dest . sin-addr. s_addr = inet_addr ( " 10 . 0 . 2 . 17" ) ; dest . sin_port = htons (9090); // Step 3: Connect to the server connect (sockfd, (struct sockaddr)&dest sizeof (struct sockaddr_in)); // Step 4: Send data to the server char *buffer! - "He 0 Server ! "; char buffer2 - "Hello Again! "; write (sockfd, bufferl, strlen (bufferl)); write (sockfd, buffer2, strlen (buffer2)); // Step 5: Close the connection close (sockefd) return 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions