Sockets Programming Assignment 1
Assigned: September 1
Due: Wednesday September 14 23:55 PM
TCP and UDP Applications Programming
For this assignment you will design and write your own application program using network sockets. You will implement two different versions of the application. One version will be based on TCP. The other will use UDP. You will write both the client and server portions of this application.
The application you are designing is a currency exchange calculator. The client interface will allow users to perform simple currency conversions. The client command should be called Exchange and should support conversions between at least the following forms of currency.
For each valid invocation, the resulting equivalent currency value(s) should be printed for the user. You will support conversion from one currency to one or more target currencies.
You must allow either the hostname or IP address of the server to be specified on the command line of the client. For instance, the command:
Exchange myserver.mynet.com 10.25 CAD EUR INR
would convert from Canadian dollars to Euros and Rupees and might produce the output:
10.25 CAD
6.47 EUR
363.45 INR
This query would have been sent to the server myserver.mynet.com. Note that if you want to query a server application running on the same computer as the client you can always use the loopback address, 127.0.0.1.
The only output of the program should be the numeric output with units or an error message if it fails.
When you build this application you are to assume that the client program is not capable of doing the math itself. Instead, the client must request the result from the server.
You will need to support fractional units down to the 100's place (e.g. dollars and cents). I strongly suggest that you consider designing your program and application protocol such that the internal representation is in hundredths. This eliminates the need to deal with floating point in your transfer protocol. Make sure that you do sufficient error handling such that a user can't crash your server. For instance, what will you do if a user provides invalid input? What about a negative value? What about a number larger than 4 billion? (It could be Bill Gates trying to buy a country afterall.)
Your server application should listen for requests from Exchange clients, process the requested operation(s) and return the result. After responding to a request the server should then listen for more requests. The server application should be designed so that it will never exit as a result of a client user action.
You can use hardcoded currency exchange rates in your server. For today's exchange rates, do some lookups on one of the many Internet services such as http://www.xe.com/ucc/ .
Notes:
Turnin Instructions:
You will be graded on the correctness of the code and its readability and structure. Your source code and supporting documentation will account for one-half of your homework grade. The other half of the grade comes from the execution testing itself. As you write the documentation, imagine that I intend to implement your protocol in my own client that will interoperate with your server. Make sure I don't have to read your source code to figure out how to do this.