Starting from:
$30

$24

Lab 1a: Sockets Solution

1. Overview




This lab is intended to get you familiarized with Java socket programming under a Linux environment. The goal is to complete and run a simple server program with Java sockets*.




*Make sure you understand LAB-320's machines Linux environment.









2. Statement of Work




Complete ~css434/lab1a/EchoServer.java that receives an ASCII message from a telnet client and simply echos it back to the client.




EchoServer.java: opens a ServerSocket at a given port and goes into the



following loop: (1) wait for a new client connection, (2) read a byte message, (3) simply echo it back, and (4) close this client connection.




If you cannot find the EchoServer.java in the folder stated above, get it from here /CSSDIV




/classes/434/lab1a




i.e.,




cp /CSSDIV/classes/434/lab1a/EchoServer.java .




To compile your programs, type:




yourlogin@uw1-320-10:~/lab1a$ javac EchoServer.java






Run your server program first and then ssh




yourlogin@uw1-320-10:~/lab1a$ java EchoServer port yourlogin@uw1-320-11:~/lab1a$ telnet uw1-320-10 port






yourlogin@uw1-320-10:~/lab1a$ java EchoServer 12345






yourlogin@uw1-320-11:~/lab1a$ telnet uw1-320-10 12345




Connected to uw1-320-10.




Escape character is '^]'.




Hi!




Hi!






Connection closed by foreign host.




yourlogin@uw1-320-11:~/lab1a$









Take a snapshot of the program’s execution.














Related Materials



To understand Java sockets, see slides: p5 - 7 of IPC slides



























































































































































































More products