SOURCE CODE for client which connects to the local server

import java.net.*;
import java.io.*;
import java.awt.*;

// set up a Client that will read and display information sent from a Server

public class Client extends Frame {

   TextArea display;

   public Client()
   {
	super( "Client" );
	display = new TextArea (20, 5);
	add( "Center", display);
	resize( 300, 150);
	show();
   }
 
   public void runClient()
   {
	Socket client;
	InputStream input;

	try
	{	
		client = new Socket (InetAddress.getLocalHost(), 5000 );
		display.appendText( "Created Socket\n");
		input = client.getInputStream();
		display.appendText( "Created input stream\n");
		
		display.appendText( "The text from the server is:\n\t");
		char ch;

		while ( ( ch = (char) input.read() ) != '\n' )
			display.appendText( String.valueOf( ch ) );
		display.appendText( "\n");
		client.close();
	}
	catch (IOException e)
	{	e.printStackTrace();	}
   }

   public boolean handleEvent (Event evt)
   {
	if (evt.id == Event.WINDOW_DESTROY)
	{
		hide();
		dispose();
		System.exit( 0 );
	}
	return super.handleEvent (evt);
   }

   public static void main( String args[] )
   {
	Client cli = new Client();

	cli.runClient();
   }
}