Description
Networking
Specification
Your server will run as a standalone program from the command line and will use the protocol specified below.
Command Line Execution
The server program will take up to two parameters, optionally – the maximum number of messages stored and the port. If not provided, the port should default to 5514, while the number of messages should default to 20:
$ ./wallserver Queue size 20, Port 5514
$ ./wallserver 30 Queue size 30, Port 5514
$ ./wallserver 35 7777 Queue size 35, Port 7777
Server Behavior
When a client connects, the server should send the wall’s contents and a prompt as shown below (Figure 2a). If there are no message entries, it should instead send “[NO MESSAGES – WALL EMPTY]” (Figure 2b).
| Wall Contents
————- Ted: Iron Maiden? Bill: Excellent! Liz: Look! I am a human doing human things!
Enter command: _ |
||
| Figure 2a. Wall display with contents. | Figure 2b. Wall display without contents. |
The server will accept four distinct commands – clear, post, kill, and quit. For commands that do not cause the user to disconnect (kill and quit), the server should send the wall’s contents and prompt the user for an additional command as shown in the example output.
| Enter command: clear↵
Wall cleared. Wall Contents ————- [NO MESSAGES – WALL EMPTY] |
clear
Clears the wall of all entries on the wall. In addition, the server should send a message indicating that the wall has been cleared. In addition, the server should send the wall’s contents to verify that the wall has in fact been cleared out correctly.
| Wall Contents
————- Jimmy Dean: Try my breakfast delights! Johnny 5: I’m alive!!
Enter command: post↵ Enter name: Bobo↵ Post [Max length 74]: Hullo.↵ Successfully tagged the wall.
Wall Contents ————- Johnny 5: I’m alive!! Bobo: Hullo.
Enter command: _
|
post
Indicates the user wishes to tag the wall. The user should be prompted for their name, followed by a message. The entire post should not exceed 80 characters (including name and separator), so the maximum length of the message should be indicated to the users. If the message is too long, the server should display the message “Error: message is too long!”; otherwise, it should display “Successfully tagged the wall.”
If the wall is “full” (the number of messages stored has reached the maximum), the oldest message (at the top) should be removed from the wall to make room for the new message post. Following the post attempt, the wall’s contents should be displayed and the user prompted for the next command. An example (with queue size 2) is shown on the right.
| Wall Contents
————- Jimmy Dean: Try my breakfast delights! Enter command: post↵ Enter name: Johnny 5↵ Post [Max length 70]: I’m alive!!! ↵ Successfully tagged the wall.
|
Wall Contents
————- Jimmy Dean: Try my breakfast delights! Enter command: post↵ Enter name: ~~~[[[[[[[[[[[THE PLAGUE]]]]]]]]]]]~~~↵ Post [Max length 40]: 12345678901234567890123456789012345678901↵ Error: message is too long! |
| Enter command: kill↵
Closing socket and terminating server. Bye! $ _ |
kill
Causes the server to shut down (terminate), and close the socket, disconnecting the user.
| Enter command: quit↵ Come back soon. Bye! $ _ |
quit
Displays a termination message and closes the client’s socket, but does not shut down the server or clear the wall.
Debugging
It is recommended that students debug their server using the netcat command line utility (with alias nc). To do so, run your server in one ssh session, then open another and run netcat:
| $ ./wallserver 2↵ Wall server running on port 5514 with queue size 2.
Students are recommended to
|
$ netcat localhost 5514 ↵
Wall Contents ————- Pigeon: You’ve got mail. Err, I mean, cooo. Coooo.
Enter command: quit↵ Come back soon. Bye! $ _ |





