C Program UDP non blocking server and client CS 2073 Handout 5 Fall 2014 Program 8 - 77927

Solution Posted by


Rating : (19)A+
Solution Detail
Price: $20.00
Request Description
C Program UDP non blocking server and client CS 2073 Handout 5 Fall 2014 Program 8 A client and server program to send short text messages over a network The code you are provided is for two different programs. The file udpclient.c solicits a line of text from the user and sends it to the IP address that the user provides. The text is sent in a UDP datagram, which is an unreliable delivery service. The sender of a UDP datagram has no way of knowing if it was received. The file udpserver.c implements a very simple service protocol: listen for udp datagrams and when one is received, write the contents to the screen. We will discuss these programs in class. You assignment is to modify the udpserver to send the datagram it receives back to the client. The udpclient should be modified to receive this datagram that is sent back and write it to the screen. Note that because udp datagrams may be lost, the client should not wait forever for one to arrive. This will require what is known in LINUX as non-blocking I/O. Initially, you should just compile and run these programs on LINUX machines and successful run them. Do not make modifications until you have successfully run them in the current form. Here are some hints to help with this process. Make sure any firewalls or filters on your test machines are turned off First test them on the same machine, each one running in different terminal windows. When you do this, the target address with be 127.0.01 Next test them on different machines. On LINUX, one way to find the address of a machine is to run the command ifconfig –a. Be careful if this command returns multiple network adapters each with a distinct address. This can confuse the server program. Make sure you have connectivity between the client machine and the server machine. Use the ping command to confirm this. You should submit the source code of both programs in a zip or gzip file. Be sure to comment he changes you made. Here are some questions you will need to answer while working on this assignment: 1. How does the server know what address to use to send the datagram back? 2. How does it know how long the received message is? 3. Will the client still send the datagram if the server is not running? 4. Will the server work if multiple clients are sending datagrams to it at the same time? These programs use the socket API to access the network services provided by LINUX. Most of the complication you see in this code involves the data structures needed by the API in order to fill in the source and destination addresses and port number of the datagram. Port numbers are used to multiplex UDP (and TCP) data delivery to specific applications running on the communicating computers.
Solution Description

C Program UDP n