Mercurial > hg > Members > you > TreeVNC
changeset 52:d8f8123dcefc
modify testDataInputStream.java
author | one |
---|---|
date | Tue, 22 May 2012 17:12:21 +0900 |
parents | a14076dac503 |
children | 923513c47b8f |
files | src/treeVnc/DataInputStream1.java src/treeVnc/MyRfbProtoClient.java src/treeVnc/RfbProto.java src/treeVnc/VncProxyService.java |
diffstat | 4 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/treeVnc/DataInputStream1.java Sun May 06 20:35:51 2012 +0900 +++ b/src/treeVnc/DataInputStream1.java Tue May 22 17:12:21 2012 +0900 @@ -5,8 +5,11 @@ import java.io.DataInputStream; import java.io.IOException; import java.net.DatagramSocket; +import java.net.ServerSocket; import java.net.Socket; import java.nio.ByteBuffer; +import java.nio.channels.ScatteringByteChannel; +import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.nio.channels.spi.AbstractSelectableChannel; @@ -22,21 +25,20 @@ public DataInputStream1() { } - - - + @Override public void readFully(byte[] b, int off, int len) throws IOException { long count = 0; ByteBuffer[] bf = {ByteBuffer.wrap(b)}; while(count < len) { - long i = channel.read(bf, off, len); + long i = channel.read(bf, off, 1); if(i==-1) { throw new IOException(); } count += i; } buf = bf[0]; + buf.position(0); } @Override
--- a/src/treeVnc/MyRfbProtoClient.java Sun May 06 20:35:51 2012 +0900 +++ b/src/treeVnc/MyRfbProtoClient.java Tue May 22 17:12:21 2012 +0900 @@ -140,6 +140,10 @@ } + public MyRfbProtoClient(DataInputStream1 d) { + is = d; + } + void sendProxyFlag(OutputStream os) throws IOException { if(proxyFlag) os.write(1); else os.write(0);
--- a/src/treeVnc/RfbProto.java Sun May 06 20:35:51 2012 +0900 +++ b/src/treeVnc/RfbProto.java Tue May 22 17:12:21 2012 +0900 @@ -254,7 +254,7 @@ timedKbits = 0; } - private Socket newSocket(String host, int port) throws IOException { + public Socket newSocket(String host, int port) throws IOException { SocketChannel ssChannel = SelectorProvider.provider().openSocketChannel(); ssChannel.socket().setReuseAddress(true); // this should work for IPv6/IPv4 dual stack @@ -282,7 +282,7 @@ while(i.hasMoreElements()) { NetworkInterface n = i.nextElement(); InetAddress a = n.getInterfaceAddresses().get(0).getBroadcast(); - ssChannel.socket().bind(new InetSocketAddress(a,port)); + ssChannel.socket().connect(new InetSocketAddress(a,port)); } } catch (SocketException e) { // for some bad IPv6 implementation @@ -784,7 +784,7 @@ // Read the server message type // - int readServerMessageType() throws IOException { + public int readServerMessageType() throws IOException { int msgType = readU8(); // If the session is being recorded: @@ -805,7 +805,7 @@ int updateNRects; - void readFramebufferUpdate() throws IOException { + public void readFramebufferUpdate() throws IOException { skipBytes(1); updateNRects = readU16(); // System.out.println(updateNRects); @@ -824,7 +824,7 @@ int updateRectX, updateRectY, updateRectW, updateRectH, updateRectEncoding; - void readFramebufferUpdateRectHdr() throws Exception { + public void readFramebufferUpdateRectHdr() throws Exception { updateRectX = readU16(); updateRectY = readU16(); updateRectW = readU16();
--- a/src/treeVnc/VncProxyService.java Sun May 06 20:35:51 2012 +0900 +++ b/src/treeVnc/VncProxyService.java Tue May 22 17:12:21 2012 +0900 @@ -131,7 +131,7 @@ try { - rfb = new MyRfbProtoProxy(host, port, true); + rfb = new MyRfbProtoProxy(); rfb.initOnce(); //rfb.close(); } catch (IOException e1) {