Mercurial > hg > Members > nobuyasu > tightVNCProxy
view src/test/VncServerTest.java @ 182:8a0e30e527e7
add test/Rfb.java test/VncClient.java test/VncServer.java
author | e085711 |
---|---|
date | Tue, 25 Oct 2011 04:51:23 +0900 |
parents | |
children |
line wrap: on
line source
package test; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; public class VncServerTest implements java.lang.Runnable { String host; int acceptPort; Rfb rfb; Thread th; ServerSocket sock; public static void main(String[] argv) { VncServerTest s = new VncServerTest(argv); try { s.init(); }catch (IOException e) { e.printStackTrace(); } s.startThread(); } VncServerTest(String[] argv) { acceptPort = Integer.parseInt(argv[0]); rfb = new Rfb(); } void init() throws IOException { sock = new ServerSocket(acceptPort); th = new Thread(this); } void startThread() { th.start(); } public void run() { try { System.out.println("accept Port number : "+ acceptPort); Socket cli = sock.accept(); InputStream is = cli.getInputStream(); OutputStream os = cli.getOutputStream(); rfb.sendRfbVersion(os); int rfbMinor = rfb.readVersionMsg(is, os); rfb.sendSecurityType(os); rfb.readSecType(is); rfb.sendSecResult(os, is); }catch(IOException e) { e.printStackTrace(); } } }