Changeset 27
- Timestamp:
- Aug 21, 2012 12:26:43 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
VSNClient/appClientModule/ClientProxy.java
r23 r27 40 40 int fwdUdpPort = 5601; 41 41 42 if(args.length >= 1){ 43 port = Integer.parseInt(args[0]); 44 } 45 if(args.length >= 3){ 46 fwdProxyServer = args[1]; 47 fwdProxyPort = Integer.parseInt(args[2]); 48 } 49 if(args.length >= 4){ 50 udpport = Integer.parseInt(args[3]); 51 } 52 if(args.length >= 5){ 53 fwdUdpPort = Integer.parseInt(args[4]); 54 } 55 42 56 // create and start the ClientProxy thread, using a 20 second timeout 43 57 // value to keep the threads from piling up too much 44 58 System.err.println(" ** Starting ClientProxy on port " + port + ". Press CTRL-C to end. **\n"); 45 ClientProxy jp = new ClientProxy(port, fwdProxyServer, fwdProxyPort, 5);46 jp.setDebug(1, System.out); // or set the debug level to 2 for tons of output47 jp.start();59 ClientProxy cp = new ClientProxy(port, fwdProxyServer, fwdProxyPort, 5); 60 cp.setDebug(1, System.out); // or set the debug level to 2 for tons of output 61 cp.start(); 48 62 49 jp.udpthread = new UDPClientThread(udpport, fwdUdpPort, fwdProxyServer, jp.conn);50 63 cp.udpthread = new UDPClientThread(udpport, fwdUdpPort, fwdProxyServer, cp.conn); 64 cp.udpthread.start(); 51 65 52 66 // run forever; if you were calling this class from another … … 62 76 // if we ever had a condition that stopped the loop above, 63 77 // we'd want to do this to kill the running thread 64 // jp.closeSocket();78 //cp.closeSocket(); 65 79 //return; 66 80 } … … 176 190 System.out.println("Table does not exist"); 177 191 Statement stmt = conn.createStatement(); 178 stmt.executeUpdate("CREATE TABLE ClientHashlist (UrlHash VARCHAR( 36) NOT NULL PRIMARY KEY, ObjectHash VARCHAR(36) NOT NULL, hashTime TIMESTAMP NOT NULL)");192 stmt.executeUpdate("CREATE TABLE ClientHashlist (UrlHash VARCHAR(40) NOT NULL PRIMARY KEY, ObjectHash VARCHAR(40) NOT NULL, hashTime TIMESTAMP NOT NULL)"); 179 193 Statement stmt2 = conn.createStatement(); 180 194 stmt2.executeUpdate("CREATE INDEX hashIndex on ClientHashlist(UrlHash ASC)"); … … 261 275 public void informUDPserver() 262 276 { 277 System.out.println("Sending 'Hello' message to VSN Server"); 263 278 String msg = "Hello"; 264 279 try{ 265 DatagramPacket firstpacket = new DatagramPacket(msg.getBytes(), msg.length(), InetAddress.getBy Address(fwdServer.getBytes()), fwdUdpPort);280 DatagramPacket firstpacket = new DatagramPacket(msg.getBytes(), msg.length(), InetAddress.getByName(fwdServer), fwdUdpPort); 266 281 UDPClient.send(firstpacket); 267 282 } … … 294 309 try{ 295 310 UDPClient.receive(receivePacket); 296 String IPAddress = new String(receivePacket.getAddress().getAddress());311 String IPAddress = receivePacket.getAddress().getHostAddress(); 297 312 int port = receivePacket.getPort(); 298 313 … … 300 315 String data = new String(receivePacket.getData()); 301 316 String [] data_array = data.split("\n"); 317 302 318 for(int i=0;i<data_array.length;i++){ 303 319 if(data_array[i].length()>0){ … … 336 352 } 337 353 } 354 System.out.println("Updated client hashlist by adding/updating "+(data_array.length-1)+" entries"); 338 355 } 339 356 } … … 475 492 urldigest.append(Integer.toHexString(0xFF & udigest[i])); 476 493 } 477 494 System.out.println(urldigest); 478 495 try { 479 496 Statement stmt2 = conn.createStatement();
Note: See TracChangeset
for help on using the changeset viewer.