|
|
||
CS 555 - Computer NetworksHW3Spring 2005
This programming assignment will require heavy use of the Berkeley UNIX Networking facilities (often called The BSD Socket Interface). You will use the socket interface to implement a simple, Internet chat room services. Your implementation will consist of both a client and a server application. The client can allow users to login, send messages to other active users, and receive messages from other active users, logout, and quit the chat room. The server verifies the identity of the users, forwards the message to the destination, and monitors clients’ activities. Write two programs, a server and a client. The server creates a socket in the Internet domain bound to port SERVER_PORT (a constant you should define in both programs, you may use last 4 digits of your WMU-ID or your SSN). The server receives requests through this socket, acts on those requests, and returns the results to the requester. The client will also create a socket in the Internet domain, send requests to the SERVER_PORT of a computer specified on the command-line, and receive responses through this socket from a server. For this assignment, you just need to allow one active client connect to the server. In the next assignment, you will allow multiple clients to connect to the server (via multithreading) at the same time. You will need to implement the following commands on the client side and the corresponding functionality on the server side. 1. login [UserID] [Password] Identify yourself to the remote talk server. If the UserID is not specified, the client will prompt the user for it. If the Password is not specified, the client will prompt the user for it. If the user is authorized (i.e., the UserID and the Password match), the server will send a confirmation message to the client; otherwise, the server will send an error message to the client. 2. send Send a message to the remote server. When a server receives a message, it will reply to the client with the same message preceded by the UserID. 3. New Create a new user account. The length of both the UserID and Password should be between 3 and 13 ASCII characters. The users’ information should be kept in a permanent media, such as a file. 4. logout Logout from the remote server. A user is not allowed to send any message after logout. 5. quit Terminate the talk session with the remote server. The client exits when it receives the confirmation message from the server. Programming Environment
Requirements The following items are required for full-credit: Implement all five commands: login, send, new, logout, and quit. Authorization information should be maintained by the server. You must have the following users (case insensitive) in your system: UserID Password Daman Auvenshine ·A user can only send the message to the server after its identity has been verified by the server. Both the server and client should be able to run on any linux / unix workstations in the cs department or CAE labs.. The client should be able to connect to the server running on any machine. Therefore, the server IP address should be a command line parameter. The server should output all client activities on the screen. When the previous client exits, the server should allow the next client connect without restarting the server. Your source codes must be well documented and commented Include a README file in your submission. The following information should be included: functions that have been implemented, instructions about how to run your program, known bugs, and sample outputs. Include a Makefile in your submission. Your Makefile might be the exact same as the sample Makefile if your file names are the same as those of the sample codes. However, you may want to use more meaningful names and modify the Makefile appropriately. Grading (150 points) Correctness and Robustness (120 points) o You will lose at least 10 points for any bugs that cause the system crash. o You will lose 5 points for any other bugs. Comments and style (10 points) README and Makefile (10 points) Design and Performance (10 points) o Limit the communication between the client and the server. If something can be done locally at the client side, you should not ask the server to do it. For example, checking the validity of a user command should be done at the client side. o Don’t make the client a dummy terminal. Sample output Sample client outputs, the words in bold are the user inputs. csy02:~/cs555/hw3% clientTalk 141.218.143.217 Simple Internet Chat Room: HW3: Computer Networks Here, list commands available for the users, and instructions. chat>send Permission denied, you must login first. chat>login UserID: tERRY Password: GooDmAN SERVER# Terry joined the chat room chat>send Please input your message: Hello, Everyone SERVER#Terry: Hello, Everyone chat>send Please input your message: Good Bye SERVER#Terry: Good Bye chat> quit SERVER#Terry has left the chat room csy02:~/cs555/hw3% Be creative in your design. Hints Start early. These programs will not be very long, but they may be difficult to write, and they will certainly be difficult to debug. Download the sample codes, compile and run them, try to understand every detail, and then make the changes. Design your own communication
protocols between the client and the server. Submission Instruction (1) Copy all your files (only source codes, data file, README, and Makefile, no object file and executable file) in a directory. The directory should be named like hw3_cs555_yourlastname/. For example, if you name is John Smith, your directory name should be hw3_cs555_smith/.. (2) Generate a tar file of the directory using the following command. Go to the parent directory of your hw3_cs555_yourlastname directory and type % tar cvf hw3_cs555_yourlastname_mmddyy.tar hw3_cs555_yourlastname %gzip hw3_cs555_yourlastname_mmddyy.tar Note, only the zipped tar file will be accepted. You are fully responsible for generating the right tar file.
(4) Submit a hardcopy of your submission with README file on top.
Sample Programs and Makefiles
References 1. Beej's Guide to Network Programming: Using Internet Sockets 2. Sun Programming Interfaces Guide: Socket Interfaces 4. Sockets
programming in Java: A tutorial
|
||