Author: jfrederic.clere(a)jboss.com
Date: 2008-10-22 05:07:12 -0400 (Wed, 22 Oct 2008)
New Revision: 1979
Added:
sandbox/mod_jk/PongClient.java
Log:
A client to test cping/pong timeouts.
Added: sandbox/mod_jk/PongClient.java
===================================================================
--- sandbox/mod_jk/PongClient.java (rev 0)
+++ sandbox/mod_jk/PongClient.java 2008-10-22 09:07:12 UTC (rev 1979)
@@ -0,0 +1,55 @@
+import java.io.*;
+import java.net.*;
+
+class PongClient {
+ public static void main(String[] argv)
+ {
+ int wait = 3000;
+ String host = "localhost";
+ if (argv.length == 2) {
+ wait = Integer.parseInt(argv[0]);
+ host = argv[1];
+ }
+ System.out.println("PongClient wait: " + wait + " to: " + host);
+ Socket clientSocket = null;
+ try {
+ clientSocket = new Socket(host, 8009);
+ } catch (IOException e) {
+ System.out.println("Could not connect on port: 8009");
+ System.exit(-1);
+ }
+ byte[] buf = new byte[1024];
+ int num;
+ byte cpong[] = { 'A' , 'B', '\0' , (byte)0x01 , (byte)0x09 };
+ byte cping[] = { (byte)0x12, (byte)0x34, '\0' , (byte)0x01 , (byte)0x0A };
+ InputStream clientInput = null;
+ OutputStream clientOutput = null;
+ try {
+ clientSocket.setSoTimeout(wait);
+ clientInput = clientSocket.getInputStream();
+ clientOutput = clientSocket.getOutputStream();
+
+ clientOutput.write(cping);
+
+ while ((num = clientInput.read(buf)) != -1) {
+ System.out.println(".");
+ int i;
+ for (i=0; i<cpong.length; i++)
+ if (cpong[i] != buf[i])
+ break;
+ if (i == cpong.length)
+ break; /* Done */
+ }
+ System.out.println("num " + num);
+ } catch (InterruptedIOException e) {
+ e.printStackTrace();
+ System.exit(-1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("Could not read from port: 8009");
+ System.exit(-1);
+ }
+
+
+ }
+}
Show replies by date