// create ServerSocket, specify port
ServerSocket ss = new ServerSocket( 8888 );
// server thread waits here for client
Socket s = ss.accept();
// get streams to allow us to read
// and write to client
BufferedReader in = new BufferedReader(
new InputStreamReader( s.getInputStream() )
);
PrintStream out = new PrintStream( s.getOutputStream() );
// read and write to client
String t = in.readLine();
System.out.println( t );
out.println( “Hi” );
out.flush();