comparison src/main/java/alice/daemon/OutboundTcpConnection.java @ 361:60eee1fb0fd3 multicast

create sender with udp
author sugi
date Thu, 15 May 2014 18:29:30 +0900
parents 8f71c3e6f11d
children
comparison
equal deleted inserted replaced
360:6cf08aebfc31 361:60eee1fb0fd3
1 package alice.daemon; 1 package alice.daemon;
2 2
3 import java.io.IOException;
4 import alice.datasegment.Command; 3 import alice.datasegment.Command;
5 4
6 public class OutboundTcpConnection extends Thread { 5 public class OutboundTcpConnection extends Thread {
7 6
8 public Connection connection; 7 public Connection connection;
9 8
10 public OutboundTcpConnection(Connection connection) { 9 public OutboundTcpConnection(Connection connection) {
11 this.connection = connection; 10 this.connection = connection;
12 } 11 }
13 12
14
15
16 /** 13 /**
17 * pipeline thread for transmission 14 * pipeline thread for transmission
18 */ 15 */
19 public void run() { 16 public void run() {
20 while (true) { 17 while (true) {
21 try { 18 try {
22 Command cmd = connection.sendQueue.take(); 19 Command cmd = connection.sendQueue.take();
23 switch (cmd.type) { 20 switch (cmd.type) {
24 case CLOSE: 21 case CLOSE:
25 connection.socket.close(); 22 connection.close();
26 return; 23 return;
27 case FINISH: 24 case FINISH:
28 System.exit(0); 25 System.exit(0);
29 return; 26 return;
30 default: 27 default:
31 break; 28 break;
32 } 29 }
33 connection.write(cmd); 30 connection.write(cmd);
34 } catch (InterruptedException e) { 31 } catch (InterruptedException e) {
35 e.printStackTrace(); 32 e.printStackTrace();
36 } catch (IOException e) {
37 e.printStackTrace();
38 } 33 }
39 } 34 }
40 } 35 }
41 36
42 } 37 }