CS 475 ­ Networks Fall 2011 ­ Programming Project 1 20 points Out: September 6, 2011

advertisement
CS 475 ­ Networks
Fall 2011 ­ Programming Project 1
20 points
Out: September 6, 2011
Due: September 15 (Thursday)
Assignment
There is a TCP server (named fortune_server) running on port 5000 of csserver.evansville.edu. The assignment is to write a TCP client in C++ to communicate with this server. The server returns “fortunes” gleaned from the UNIX fortune program. The server expects to receive a line of text from the client. If the line of text starts with an integer number, then the server sends a fortune corresponding to that number to the client, otherwise the server returns a random fortune. The server will send a random fortune to the client if the server receives an empty message too.
Your client application may be a “fortune teller”, “lucky number program”, a “horoscope program” or anything else. It must however, use and display “fortunes” from the fortune server.
Your client should accept the server hostname and port number as command line arguments:
$ fortune_client csserver.evansville.edu 5000
It must use getaddrinfo() resolve the hostname to an IP address. (Using gethostent()
will be penalized.)
For full credit, your client program should use a modular or object­oriented design. (I.e., the entire program should not be in main()!) Think about creating classes that might be useful for organizing this (and future) applications. E.g., a Socket or Connection class might be used to encapsulate all of the low­level socket routine ugliness.
Notes: Due to the University firewall, only clients inside the firewall (i.e. definitely the lab machines, perhaps on wireless, too) can talk to csserver on port 5000.
It is possible that the server may not be running on csserver (due to a csserver restart or a server crash). Test the connection with telnet (telnet csserver.evansville.edu 5000) and if it is not running, notify the instructor as soon as possible.
09/05/2011
Page 1 of 2
D. Hwang
Grading
Grades for this project will be awarded based on the following criteria:
80% correctness
10% readability (including comments)
10%
elegance of design What to submit
Create a makefile that will make your application, and create a tarfile or zipfile containing it and the program source files.
● Email your tarfile/zipfile to the instructor, hwang@evansville.edu
●
09/05/2011
Page 2 of 2
D. Hwang
Download