werkende jtorx code
[tt2015.git] / a3 / code / jtorx / server / DefaultHandler.java
1 import java.net.Socket;
2 import java.net.SocketException;
3
4 /**
5 * Default connection handler. Very basic, does not read or send anything.
6 */
7 public class DefaultHandler implements Runnable {
8 private Socket socket;
9
10 public DefaultHandler(Socket socket) {
11 this.socket = socket;
12 try {
13 socket.setTcpNoDelay(false);
14 } catch (SocketException e) {
15 // TODO Auto-generated catch block
16 e.printStackTrace();
17 }
18 new Thread(this).start();
19 }
20
21 public void run() {
22 {
23 // here you can customize operations you want to test though it's not necessary
24 System.out.println("new socket opening on " + socket.getLocalPort());
25 while (!socket.isOutputShutdown()) {
26 try {
27 Thread.sleep(100);
28 } catch (InterruptedException e) {
29 // TODO Auto-generated catch block
30 e.printStackTrace();
31 }
32 }
33 }
34 }
35 }