{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Task 1 your own basic server 3 marks now its your

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: create an instance of our server, and start it going. The Server superclass we’ve provided then attaches itself to that port, and waits for incoming connections, calling the methods provided in EchoServer (onStart, onMessage etc) whenever something interesting happens, such as a client connecting, or a message being received. If you like, swap the instance of EchoServer for an instance of EgoServer, and try talking to the server once more with telnet; it should be fairly obvious what’s going on here, but ask for help if it’s not! Now let’s return to the comments at the top of the file; these document all the different methods that can be overridden to make your own server implementation. Make sure you’ve read the comments thoroughly, and ask for help if they don’t make sense. Task 1 : your own basic server [3 marks] Now it’s your turn to write some code. Your first task is to create a server that simply acknowledges that it has started, that a client has connected, that it has received a message, that a client has disconnected, or that it has been instructed to stop. All you need to do here is print out a suitable message on screen for each. You should be able to test all of these eventualities using telnet, as we did for EchoServer and EgoServer. Hint : your server is going to be very similar to our EchoServer implementation, but with a few more methods implemented (and these methods are explained in a lot of detail at the top of the file!) If you decide to stop the lab work here, you’ll get up to 3 marks out of the possible 20 for this ‘printing things out server’ – you might want to save what you’ve done so far in a different file in case you need to revert to it later. Task 2 : counting clients [2 marks] Still using telnet as a client, arrange for the server to remember the number of currently active clients, printing out the new total every time a client connects or disconnects. If you decide to stop the lab work here, you’ll get up to 2 more marks for making this bit work. Task 3 : accepting commands [2 marks] So now you have a basic ‘generic’ server; it will sit and listen for incoming connections, and handle messages sent to it in tex...
View Full Document

{[ snackBarMessage ]}