4 public class DemoServer extends Thread
6 ServerSocket listenSock;
8 public static void main(String[] args)
10 DemoServer app = new DemoServer();
23 listenSock = new ServerSocket(5758);
24 System.out.println(listenSock.toString());
25 } catch (Exception hell) {
26 System.out.println("Error setting up listen socket:\n");
27 System.out.println(hell);
34 System.out.println("Trying accept");
35 newSocket = listenSock.accept();
36 System.out.println("Accept returned");
37 } catch (Exception badAccept) {
40 System.out.println("Accepted new client");
43 DataInputStream inStream = new DataInputStream(
44 newSocket.getInputStream());
45 System.out.println("Client send "+inStream.readInt());
47 } catch (Exception oops) {
48 System.out.println("Error reading from client");
49 System.out.println(oops);