# HG changeset patch # User one # Date 1335183023 -32400 # Node ID 970d5ac8025672b404182f5f9437ad53d9d32ea0 # Parent 657c691c293635dfac78e03bc96f0fec95f845c7 add MyDataInputStream.java and DataInputStream1.java diff -r 657c691c2936 -r 970d5ac80256 src/treeVnc/DataInputStream1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treeVnc/DataInputStream1.java Mon Apr 23 21:10:23 2012 +0900 @@ -0,0 +1,65 @@ +package treeVnc; + +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.IOException; + + +public class DataInputStream1 implements MyDataInputStream { + DataInputStream is; + public DataInputStream1(BufferedInputStream bufferedInputStream) { + is = new DataInputStream(bufferedInputStream); + } + + @Override + public void readFully(byte[] b, int off, int len) throws IOException { + is.readFully(b, off, len); + } + + @Override + public int available() throws IOException { + return is.available(); + } + + @Override + public int skipBytes(int n) throws IOException { + return is.skipBytes(n); + } + + @Override + public int readUnsignedByte() throws IOException { + return is.readUnsignedByte(); + } + + @Override + public int readUnsignedShort() throws IOException { + return is.readUnsignedShort(); + } + + @Override + public int readInt() throws IOException { + return is.readInt(); + } + + @Override + public void read(byte[] headBuf) throws IOException { + is.read(headBuf); + } + + @Override + public boolean markSupported() { + return is.markSupported(); + } + + @Override + public void mark(int i) { + is.mark(i); + } + + @Override + public void reset() { + // TODO Auto-generated method stub + + } + +} diff -r 657c691c2936 -r 970d5ac80256 src/treeVnc/MyDataInputStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treeVnc/MyDataInputStream.java Mon Apr 23 21:10:23 2012 +0900 @@ -0,0 +1,27 @@ +package treeVnc; + +import java.io.IOException; + +public interface MyDataInputStream { + + void readFully(byte[] b, int off, int len) throws IOException; + + int available() throws IOException; + + int skipBytes(int n) throws IOException; + + int readUnsignedByte() throws IOException; + + int readUnsignedShort() throws IOException; + + int readInt() throws IOException; + + void read(byte[] headBuf) throws IOException; + + boolean markSupported(); + + void mark(int i); + + void reset(); + +} diff -r 657c691c2936 -r 970d5ac80256 src/treeVnc/MyRfbProtoClient.java --- a/src/treeVnc/MyRfbProtoClient.java Mon Apr 23 20:53:18 2012 +0900 +++ b/src/treeVnc/MyRfbProtoClient.java Mon Apr 23 21:10:23 2012 +0900 @@ -165,7 +165,7 @@ port = p; sock = new Socket(host, port); - is = new DataInputStream(new BufferedInputStream(sock.getInputStream(),16384)); + is = new DataInputStream1(new BufferedInputStream(sock.getInputStream(),16384)); os = sock.getOutputStream(); timing = false; @@ -393,10 +393,10 @@ cliListTmp.clear(); } - boolean ready() throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - return br.ready(); - } +// boolean ready() throws IOException { +// BufferedReader br = new BufferedReader(new InputStreamReader(is)); +// return br.ready(); +// } int cliSize() { return cliList.size(); @@ -407,48 +407,48 @@ } - Runnable sendr = new Runnable() { - public void run() { - broadCastCommnication(); - } - }; +// Runnable sendr = new Runnable() { +// public void run() { +// broadCastCommnication(); +// } +// }; - void mcastStart(){ - new Thread(sendr).start(); - } +// void mcastStart(){ +// new Thread(sendr).start(); +// } - void broadCastCommnication() { - String mcastAddr = "224.0.0.1"; - int port = 8192; - int bufSize = 1024; - - String recvData; - is = new DataInputStream(new ByteArrayInputStream(broadCastBuf)); - - try { - InetAddress mAddr = InetAddress.getByName(mcastAddr); - MulticastSocket soc = new MulticastSocket(port); - DatagramPacket recvPacket = new DatagramPacket(broadCastBuf, bufSize); - - soc.joinGroup(mAddr); - //System.out.println("マルチキャスト"+mcastAddr+"に参加します"); - - while(true) { - soc.receive(recvPacket); - recvData =new String(recvPacket.getData()); - recvData = recvData.trim(); - if(recvData.equals("quit")) { - break; - } - // System.out.println(recvData); - } - soc.leaveGroup(mAddr); - soc.close(); - } catch(IOException e) { - e.printStackTrace(); - } - } +// void broadCastCommnication() { +// String mcastAddr = "224.0.0.1"; +// int port = 8192; +// int bufSize = 1024; +// +// String recvData; +// is = new DataInputStream(new ByteArrayInputStream(broadCastBuf)); +// +// try { +// InetAddress mAddr = InetAddress.getByName(mcastAddr); +// MulticastSocket soc = new MulticastSocket(port); +// DatagramPacket recvPacket = new DatagramPacket(broadCastBuf, bufSize); +// +// soc.joinGroup(mAddr); +// //System.out.println("マルチキャスト"+mcastAddr+"に参加します"); +// +// while(true) { +// soc.receive(recvPacket); +// recvData =new String(recvPacket.getData()); +// recvData = recvData.trim(); +// if(recvData.equals("quit")) { +// break; +// } +// // System.out.println(recvData); +// } +// soc.leaveGroup(mAddr); +// soc.close(); +// } catch(IOException e) { +// e.printStackTrace(); +// } +// } diff -r 657c691c2936 -r 970d5ac80256 src/treeVnc/MyRfbProtoProxy.java --- a/src/treeVnc/MyRfbProtoProxy.java Mon Apr 23 20:53:18 2012 +0900 +++ b/src/treeVnc/MyRfbProtoProxy.java Mon Apr 23 21:10:23 2012 +0900 @@ -402,10 +402,10 @@ cliListTmp.clear(); } - boolean ready() throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - return br.ready(); - } +// boolean ready() throws IOException { +// BufferedReader br = new BufferedReader(new InputStreamReader(is)); +// return br.ready(); +// } int cliSize() { return cliList.size(); diff -r 657c691c2936 -r 970d5ac80256 src/treeVnc/RfbProto.java --- a/src/treeVnc/RfbProto.java Mon Apr 23 20:53:18 2012 +0900 +++ b/src/treeVnc/RfbProto.java Mon Apr 23 21:10:23 2012 +0900 @@ -137,7 +137,7 @@ // only via RfbProto methods. We have to do this because we want to // count how many bytes were read. // private DataInputStream is; - protected DataInputStream is; + protected MyDataInputStream is; // private long numBytesRead = 0; protected long numBytesRead = 0; @@ -216,7 +216,7 @@ throw new IOException(e.getMessage()); } } - is = new DataInputStream(new BufferedInputStream(sock.getInputStream(), + is = new DataInputStream1(new BufferedInputStream(sock.getInputStream(), 16384)); os = sock.getOutputStream(); @@ -231,7 +231,7 @@ sock = newSocket(host, port); - is = new DataInputStream(new BufferedInputStream(sock.getInputStream(), + is = new DataInputStream1(new BufferedInputStream(sock.getInputStream(), 16384)); os = sock.getOutputStream(); @@ -286,7 +286,7 @@ host = h; sock = null; sock = newSocket(host, port); - is = new DataInputStream(new BufferedInputStream(sock.getInputStream(), + is = new DataInputStream1(new BufferedInputStream(sock.getInputStream(), 16384)); os = sock.getOutputStream();