Mercurial > hg > Members > nobuyasu > tightVNCProxy
diff src/myVncProxy/MyRfbProto.java @ 45:b16072ddc911
modify MyRfbProto.java acceptThread.java
author | e085711 |
---|---|
date | Wed, 06 Jul 2011 10:56:44 +0900 |
parents | ff1d1f236c8a |
children | 11da7dacbc1a |
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java Fri Jun 24 02:25:04 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Wed Jul 06 10:56:44 2011 +0900 @@ -192,6 +192,30 @@ void sendRfbVersion(OutputStream os) throws IOException{ os.write(versionMsg_3_998.getBytes()); } + void readVersionMsg(InputStream is) throws IOException { + + byte[] b = new byte[12]; + + is.read(b); + + if ((b[0] != 'R') || (b[1] != 'F') || (b[2] != 'B') || (b[3] != ' ') + || (b[4] < '0') || (b[4] > '9') || (b[5] < '0') || (b[5] > '9') + || (b[6] < '0') || (b[6] > '9') || (b[7] != '.') + || (b[8] < '0') || (b[8] > '9') || (b[9] < '0') || (b[9] > '9') + || (b[10] < '0') || (b[10] > '9') || (b[11] != '\n')) { + throw new IOException("Host " + host + " port " + port + + " is not an RFB server"); + } + + serverMajor = (b[4] - '0') * 100 + (b[5] - '0') * 10 + (b[6] - '0'); + serverMinor = (b[8] - '0') * 100 + (b[9] - '0') * 10 + (b[10] - '0'); + + if (serverMajor < 3) { + throw new IOException( + "RFB server does not support protocol version 3"); + } + + } void sendSecurityType(OutputStream os) throws IOException { // number-of-security-types os.write(1);