Mercurial > hg > Members > you > TreeVNC
changeset 50:f77309fa8a9c
client update before
author | one |
---|---|
date | Sun, 06 May 2012 15:07:46 +0900 |
parents | 13dadbb4aa5f |
children | a14076dac503 |
files | src/treeVnc/MyRfbProtoProxy.java src/treeVnc/splitBufferTest.java |
diffstat | 2 files changed, 29 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/treeVnc/MyRfbProtoProxy.java Sat May 05 18:38:10 2012 +0900 +++ b/src/treeVnc/MyRfbProtoProxy.java Sun May 06 15:07:46 2012 +0900 @@ -15,6 +15,9 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.BindException; +import java.net.DatagramPacket; +import java.net.InetAddress; +import java.net.MulticastSocket; import java.net.ServerSocket; import java.net.Socket; import java.nio.ByteBuffer; @@ -959,13 +962,37 @@ /* if socket closed cliList.remove(newCli); */ } } + + void broadcastCommunication(byte[] buf, int off ,int len) { + String mcastAddr = "224.0.0.1"; + int port = 8192; + + try { + InetAddress mAddr = InetAddress.getByName(mcastAddr); + MulticastSocket soc = new MulticastSocket(); + DatagramPacket sendPacket = null; + soc.setTimeToLive(100); + + // System.out.println("Multicast = " + mcastAddr); + // while(buf != null) { + // int len = System.in.read(buf); + sendPacket = new DatagramPacket(buf, len, mAddr, port); + soc.send(sendPacket); + // } + soc.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } public void writeToClient(final OutputStream os, LinkedList<ByteBuffer> bufs, int inputIndex) throws IOException { while (inputIndex < bufs.size()) { ByteBuffer b = bufs.get(inputIndex++); - os.write(b.array(), b.position(), b.limit()); + broadcastCommunication(b.array(),b.position(),b.limit()); + //os.write(b.array(), b.position(), b.limit()); } os.flush(); }
--- a/src/treeVnc/splitBufferTest.java Sat May 05 18:38:10 2012 +0900 +++ b/src/treeVnc/splitBufferTest.java Sun May 06 15:07:46 2012 +0900 @@ -32,7 +32,7 @@ DataInputStream dataInStream = new DataInputStream( new BufferedInputStream( - new FileInputStream("./log.txt"))); + new FileInputStream("log.txt"))); int readByte = 0,totalByte =0; while(-1 != (readByte = dataInStream.read(d))){