Mercurial > hg > Applications > TreeVNC
changeset 87:9a485070f831
close "TreeVNC-root-finder" thread.
author | oc |
---|---|
date | Thu, 01 May 2014 18:04:39 +0900 |
parents | f6946d4fe926 |
children | a719aa609e14 |
files | src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java |
diffstat | 2 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Thu May 01 10:20:11 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/CreateConnectionParam.java Thu May 01 18:04:39 2014 +0900 @@ -27,7 +27,7 @@ portNumber = 0; do { try { - Thread runBcast = new Thread(getBcast); + Thread runBcast = new Thread(getBcast, "TreeVNC-root-finder"); runBcast.start(); hostName = getBcast.textAddress(); // wait for root reply to our broadcast portNumber = Integer.parseInt(getBcast.textPort());
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java Thu May 01 10:20:11 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java Thu May 01 18:04:39 2014 +0900 @@ -30,7 +30,10 @@ public GetHostClient(String _str) { str = _str; + } + public void createSocket() { + do { try { server = new ServerSocket(port); @@ -40,9 +43,7 @@ // can't open socket } } while (server == null); - } - - public void createSocket() { + try { mAddr = InetAddress.getByName(GetBroadCastProxy.McastAddr); soc = new MulticastSocket(); @@ -52,6 +53,10 @@ } } + /** + * send find root message. + * + */ public void sendData() { String s = str + Integer.toString(port); buf = s.getBytes(); @@ -68,7 +73,13 @@ sendData(); } + + /** + * @return + * reply to findRootMassage + * + */ public String textAddress() { return text.getAddress(); } @@ -115,9 +126,8 @@ text.setButton(); text.visible(); } - System.out.println("stop"); + System.err.println("stop"); } catch (IOException e) { - e.printStackTrace(); } } @@ -127,6 +137,12 @@ } public void interrupt() { + stopFlag = true; + try { + server.close(); + soc.close(); + } catch (IOException e) { + } Thread.currentThread().interrupt(); }