Assignment 4 CS494-unp revised: 9/19/99 Assigned: 9/9/99 Due: 9/24/99 6:00pm Objective: UDP server and TCP client/server Points: 50 Description: Somewhere on the CS subnet there is a host which every 10 seconds broadcasts a UDP packet on port 18765. The 8 bytes of binary data in the packet look like the following struct Invitation { unsigned int key; unsigned short port; char pad[2]; } All fields are in network byte order. The 32-bit "key" field and 16-bit "port" field are only valid for the next 10 seconds. Within these 10 seconds, you must establish a TCP connection with the broadcast machine on the port designated by the "port" field. You can get the IP address of the broadcast machine from data returned by recvfrom(). Once you've established the connection, you should send a sizeof(struct Request) message over this TCP connection consisting of the following structure: struct Request { unsigned int key; unsigned short port; char yourname[64]; } The "yourname" field should be a null-terminated ASCII string of less than 64 characters holding your name and student ID. The "key" field should contain the key that you received from the UDP packet. The "port" field should contain the TCP port number (in network byte order) of the port that YOUR process is listening on, so that the broadcast machine can connect to you and send you a reply. (Note: you can statically assign your port and hope it's not in use, or use port 0 and let OS assign it, and then you can retrieve it after the bind() with getsockname()). The broadcast machine will attempt to establish a new TCP connection with your process on the port specified in your message and will send you the following 8-byte message (network byte order) over that TCP connection: struct Reply { unsigned int result; unsigned int receipt; } If the "result" field is non-zero then the key did not match or something else is messed up and you need to fix and try again. If the "result" field is zero, you are incredibly talented, and your program should print out the values of the "receipt" and "key" fields in hex (%x) and the IP address (w.x.y.z) AND name of the broadcast machine. Submit these values along with your source files, makefile, using the script ~dunigan/cs494-unp/494submit Do NOT use any of Stevens' libraries. Do NOT write your own broadcast server for testing. Your program will have to be running on a CS machine in order to receive the broadcast datagram. (Broadcasts do not leave subnets.) Optional: Please indicate amount of time required to complete assignment.