Mercurial > hg > Database > Alice
comparison src/main/java/alice/daemon/AcceptThread.java @ 419:aefbe41fcf12 dispose
change tab to space
author | sugi |
---|---|
date | Tue, 15 Jul 2014 16:00:22 +0900 |
parents | 8f71c3e6f11d |
children | cf0eb5b2b4d2 |
comparison
equal
deleted
inserted
replaced
418:a269a019f5f8 | 419:aefbe41fcf12 |
---|---|
8 | 8 |
9 import alice.datasegment.DataSegment; | 9 import alice.datasegment.DataSegment; |
10 | 10 |
11 public class AcceptThread extends Thread { | 11 public class AcceptThread extends Thread { |
12 | 12 |
13 private ServerSocket ss; | 13 private ServerSocket ss; |
14 private Logger log = Logger.getLogger(AcceptThread.class); | 14 private Logger log = Logger.getLogger(AcceptThread.class); |
15 public int counter = 0; | 15 public int counter = 0; |
16 | 16 |
17 public AcceptThread(ServerSocket ss, String name) { | 17 public AcceptThread(ServerSocket ss, String name) { |
18 super(name); | 18 super(name); |
19 this.ss = ss; | 19 this.ss = ss; |
20 } | 20 } |
21 | 21 |
22 @Override | 22 @Override |
23 public void run() { | 23 public void run() { |
24 while (true) { | 24 while (true) { |
25 try { | 25 try { |
26 Socket socket = ss.accept(); | 26 Socket socket = ss.accept(); |
27 socket.setTcpNoDelay(true); | 27 socket.setTcpNoDelay(true); |
28 log.info("Accept " + socket.getInetAddress().getHostName() + ":" + socket.getPort()); | 28 log.info("Accept " + socket.getInetAddress().getHostName() + ":" + socket.getPort()); |
29 Connection connection = new Connection(socket); | 29 Connection connection = new Connection(socket); |
30 String key = "accept" + counter; | 30 String key = "accept" + counter; |
31 IncomingTcpConnection incoming = | 31 IncomingTcpConnection incoming = |
32 new IncomingTcpConnection(connection, DataSegment.get("local"), key); | 32 new IncomingTcpConnection(connection, DataSegment.get("local"), key); |
33 incoming.start(); | 33 incoming.start(); |
34 DataSegment.setAccept(key, incoming); | 34 DataSegment.setAccept(key, incoming); |
35 new OutboundTcpConnection(connection).start(); | 35 new OutboundTcpConnection(connection).start(); |
36 counter++; | 36 counter++; |
37 } catch (IOException e) { | 37 } catch (IOException e) { |
38 e.printStackTrace(); | 38 e.printStackTrace(); |
39 } | 39 } |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 } | 43 } |