import java.net.*; import java.io.*; import dtai.net.*; public class Sample2 extends NetServer { public static void main ( String argv[] ) { try { int port = 8765; new Sample2( port ); } catch ( Exception e ) { e.printStackTrace(); } } public Sample2( int portnum ) { super ( portnum ); } public void createClientPort( Socket socket ) { try { new PortToClient ( this, socket ).start(); } catch( IOException ioe ) { ioe.printStackTrace(); } } } class PortToClient extends NetPortToClient { public PortToClient(Sample2 server, Socket socket) throws IOException { super( server, socket ); } protected void readInput() throws IOException { String command = readUTF(); // do something... String response = "I did it!"; writeUTF( response ); flush(); } }