Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NEED HELP WITH TCP Client and Server ! Follow these guidelines and ask questions! You should rely on the basic structure of your UDP client
NEED HELP WITH TCP Client and Server !
Follow these guidelines and ask questions! You should rely on the basic structure of your UDP client and server for homework 1 Since your target port is 50009, use a directive like #define TARGET-PORT 50009 to keep this from being confused with your source port You will need three new function calls to work with stream data (as opposed to message or datagram data from HW 4) o connect)-this is used on the client side only o listen) this is used on the server side only o accept) this is used on the server side only Another change involves the function to send and receive data. In homework 4 they were sendto) and recvfrom), but for the connection orlented TCP transport protocol, they are send0 and recv). The functionality of the client and server has been changed for this assignment as well. The client must send a message to the server as before, but it must also receive a reply indicating that the message was received. The server must be programmed to handle concurrent connections. For this server you will use multi-processing using the fork() function to clone the server process (see flow diagram at the end of this handout). A future assignment will use threads to do the same thing, The easiest way to learn about these new function calls is to look at the man pages on a LINUX system. You will also find the details in BJ's Guide on Blackboard. Keep these important concepts in mind: A server usually only calls listen() once for each socket on which it is listening for connection requests. .Connection requests are accepted by the accept() function call. The accept function returns a new socket descriptor for the connection just accepted and it may be called multiple times to handle multiple connections to the server So now that the server has two sockets, what to do? The answer is create a child process to handle the new connection and let the parent process continue to accept connection requests . Remember that the fork() call creates a clone process, complete with all the open file descriptors and socket. However, the parent process does not need the new socket descriptor, so it will close it. Likewise, the child process does not need the original socket descriptor, so it will close it. Both processes should close their working socket descriptor(s) when they finish. . Remember that once a connection is established on a stream socket descriptor, it may be used for bi directional communications without further specification of addresses and port numbers. . See Blackboard for the target IP addressStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started