try
{ sSock = new ServerSocket( port );
}
catch( IOException ioe )
{ System.out.println( "Couldn't listen on port " + port );
System.exit( -1 );
}
try
{ sock = sSock.accept();
}
catch( IOException ioe )
{ System.out.println( "Accept failed" );
System.exit( -1 );
}
try
{ ins = sock.getInputStream();
outs = sock.getOutputStream();
}
catch( IOException ioe )
{ System.out.println( "Failed to get I/O streams" );
System.exit( -1 );
}
try
{ int inChar = ins.read();
while( inChar != -1 )
{ outs.write( inChar );
outs.flush();
System.out.print( (char)inChar );
inChar = ins.read();
}
sock.close();
}
catch( IOException ioe )
{ System.out.println( "Read/write failed" );
System.exit( -1 );
}