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/ that receives an ASCII message from a telnet client and simply echos it back to the client.

  • 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 in the folder stated above, get it from here /CSSDIV



cp /CSSDIV/classes/434/lab1a/ .

To compile your programs, type:

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

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 ‘^]’.



Connection closed by foreign host.


Take a snapshot of the program’s execution.

  1. Related Materials

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

error: Content is protected !!