Problem #2 UDP Sockets
UDP Server (60 points)
Write a console program that takes as a command line argument the port number on which the UDP Server will receive messages. The UDP server collects parts of a larger composite message from the clients. The UDP server collects these message parts from different clients and assembles them in order, based on the lSeqNum. The UDP server keeps a running list of all clients that have sent a message to it and will broadcast the composite message to all clients when commanded. The UDP server needs to be able to receive data from clients without blocking the main application thread. The program needs to respond to user input while handling socket communications at the same time.
The program should continuously prompt the user for commands to execute like so: Please enter command: 0
Please enter command: 1 Please enter command: 2
Composite Msg: current composite message
The data being sent back and forth will use the following packet structure:
struct udpMessage
{
unsigned char nVersion; unsigned char nType; unsigned short nMsgLen; unsigned long lSeqNum; char chMsg[1000];
};
The UDP server needs to have the following functionality from the command prompt:
The UDP server needs to have the following functionality when receiving messages:
If the composite message becomes larger than 1000 then the composite message (up to 1000) is immediately set out to all clients and any remaining characters are used to start a new composite message with a lSeqNum = 0.
UDP Client (40 points)
In order to test your server, write a console program that takes as a command line argument
the IP Address and port number of the server as shown below:
The program should prompt the user for inputs and display any messages received. Here are example user inputs:
Please enter command: v # the user enters a “v”, a space, and then a version number. This version number is now used in all new messages.
Please enter command: t # # message string the user enters a “t”, a space, and then a type
number, and then a sequence number, followed by the message (if any). Be sure you are able to handle the spaces in the message.
Please enter command: q the user enters a “q” causes the socket to be closed and the program to terminate.
Any messages received should be displayed as followed:
Received Msg Type: 1, Seq: 33, Msg: message received
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of