I trying to write a chat application that keep record who login and logout. i already created server, class, interface, and event management. i have hard time creating client for this server.
import java.io.*; import java.net.*;
public class CommServer extends CommWatcher implements Runnable { Thread m_thread; public void run() { try { // create a 'passive' connection listening on port 1234 ServerSocket server = new ServerSocket( 1234 );
while( true ) { // wait for a connection Socket s = server.accept();
System.out.println( "Client connection" );
ClientComm comm = new ClientComm( s, this ); addCommListener( comm ); } } catch( Exception e ) { System.out.println( "Server just died..." ); } }
public CommServer() { m_thread = new Thread( this ); m_thread.start(); }
public static void main( String[] args ) { new CommServer(); } }