cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java SSLServer.java BIOSSLServer.java

2005-06-17 Thread mturk
mturk   2005/06/17 05:03:51

  Modified:jni/examples/org/apache/tomcat/jni Echo.java SSLServer.java
  Removed: jni/examples/org/apache/tomcat/jni BIOSSLServer.java
  Log:
  Update examples and remove BIOSSLServer because now
  it needs a total rewrite.
  
  Revision  ChangesPath
  1.13  +2 -2  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Echo.java 17 Jun 2005 11:23:33 -  1.12
  +++ Echo.java 17 Jun 2005 12:03:51 -  1.13
  @@ -242,7 +242,7 @@
   while (Socket.recv(clientSock, buf, 0, 1) == 1) {
   if (buf[0] == '\n')
   break;
  -else if (buf[0] == 'Q') {
  +else if (buf[0] == '!') {
   doClose = true;
   break;
   }
  
  
  
  1.9   +7 -6  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java
  
  Index: SSLServer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SSLServer.java17 Jun 2005 11:23:33 -  1.8
  +++ SSLServer.java17 Jun 2005 12:03:51 -  1.9
  @@ -142,11 +142,11 @@
   }
   
   Socket.timeoutSet(clientSock, 1000);
  -long sslSocket = SSLSocket.attach(SSLServer.serverCtx, 
clientSock, pool);
  -i = SSLSocket.handshake(sslSocket);
  +SSLSocket.attach(SSLServer.serverCtx, clientSock, pool);
  +i = SSLSocket.handshake(clientSock);
   if (i == 0) {
   
  -Worker worker = new Worker(sslSocket, i++,
  +Worker worker = new Worker(clientSock, i++,
  
this.getClass().getName());
   SSLServer.incThreads();
   worker.start();
  @@ -154,7 +154,7 @@
   }
   else {
   System.out.println(Handshake error:  + 
SSL.getLastError());
  -Socket.destroy(sslSocket);
  +Socket.destroy(clientSock);
   }
   }
   }
  @@ -186,10 +186,11 @@
   while (Socket.recv(clientSock, buf, 0, 1) == 1) {
   if (buf[0] == '\n')
   break;
  -else if (buf[0] == 'Q') {
  +else if (buf[0] == '!') {
   doClose = true;
   break;
   }
  +Socket.send(clientSock, buf, 0, 1);
   }
   if (doClose) {
   try {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java SSLServer.java

2005-06-17 Thread mturk
mturk   2005/06/17 04:23:33

  Modified:jni/examples/org/apache/tomcat/jni Echo.java SSLServer.java
  Log:
  Update examples.
  
  Revision  ChangesPath
  1.12  +13 -14
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Echo.java 28 May 2005 12:13:02 -  1.11
  +++ Echo.java 17 Jun 2005 11:23:33 -  1.12
  @@ -153,23 +153,23 @@
   }
   }
   
  -public void add(long socket, int workerId) {
  -int rv = Poll.add(serverPollset, socket, workerId,
  +public void add(long socket) {
  +int rv = Poll.add(serverPollset, socket,
 Poll.APR_POLLIN);
   if (rv == Status.APR_SUCCESS) {
  -System.out.println(Added worker  + workerId +  to 
pollset);
  +System.out.println(Added worker to pollset);
   nsocks++;
   }
   }
   
  -public void remove(long socket, int workerId) {
  +public void remove(long socket) {
   int rv = Poll.remove(serverPollset, socket);
   if (rv == Status.APR_SUCCESS) {
  nsocks--;
  -   System.out.println(Removed worker  + workerId +  from 
pollset);
  +   System.out.println(Removed worker from pollset);
   }
   else {
  -   System.out.println(Failed removing worker  + workerId +  
from pollset);
  +   System.out.println(Failed removing worker from pollset);
   }
   }
   
  @@ -180,17 +180,16 @@
   Thread.sleep(1);
   continue;
   }
  -/* Four times size then  created pollset */
  +/* Two times size then  created pollset */
   long [] desc = new long[64];
   /* USe 1 second poll timeout */
   int rv = Poll.poll(serverPollset, 100, desc, false);
   if (rv  0) {
   for (int n = 0; n  rv; n++) {
  -long clientSock = desc[n*4+1];
  -int  workerId   = (int)desc[n*4+2];
  -System.out.println(Poll flags  + desc[n*4]);
  -remove(clientSock, workerId);
  -Worker worker = new Worker(clientSock, workerId,
  +long clientSock = desc[n*2+1];
  +System.out.println(Poll flags  + desc[n*2]);
  +remove(clientSock);
  +Worker worker = new Worker(clientSock, n,
  
this.getClass().getName());
   Echo.incThreads();
   worker.start();
  @@ -262,7 +261,7 @@
   Socket.send(clientSock, msg, 0, msg.length);
   } catch(Exception e) { }
   /* Put the socket to the keep-alive poll */
  -Echo.echoPoller.add(clientSock, workerId);
  +Echo.echoPoller.add(clientSock);
   }
   } catch (Exception e) {
   Socket.close(clientSock);
  
  
  
  1.8   +14 -12
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java
  
  Index: SSLServer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SSLServer.java15 Jun 2005 15:15:54 -  1.7
  +++ SSLServer.java17 Jun 2005 11:23:33 -  1.8
  @@ -154,7 +154,7 @@
   }
   else {
   System.out.println(Handshake error:  + 
SSL.getLastError());
  -SSLSocket.close(sslSocket);
  +Socket.destroy(sslSocket);
   }
   }
   }
  @@ -179,27 +179,29 @@
   public void run() {
   boolean doClose = false;
   try {
  -SSLSocket.send(clientSock, wellcomeMsg, 0, 
wellcomeMsg.length);
  +Socket.send(clientSock, wellcomeMsg, 0, wellcomeMsg.length);
   while (!doClose) {
   /* Do a blocking read byte at a time */
   byte [] buf = new byte[1];
  -int ret;
  -ret = SSLSocket.recv(clientSock, buf, 0, 1);
  - 

cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-05-28 Thread mturk
mturk   2005/05/28 05:13:02

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  Update examples to conform to API.
  Add OS.info display.
  
  Revision  ChangesPath
  1.11  +55 -16
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Echo.java 18 Apr 2005 15:28:06 -  1.10
  +++ Echo.java 28 May 2005 12:13:02 -  1.11
  @@ -82,7 +82,7 @@
   System.out.println(Server:  + addr.servname);
   System.out.println(IP:  + Address.getip(sa) +
  : + addr.port);
  -}   
  +}
   int rc = Socket.bind(serverSock, inetAddress);
   if (rc != 0) {
 throw(new Exception(Can't create Acceptor: bind:  + 
Error.strerror(rc)));
  @@ -101,7 +101,7 @@
   while (true) {
   long clientSock = Socket.accept(serverSock, pool);
   System.out.println(Accepted id:  +  i);
  -
  +
   try {
   long sa = Address.get(Socket.APR_REMOTE, clientSock);
   Sockaddr raddr = new Sockaddr();
  @@ -117,13 +117,13 @@
   System.out.println(Local Server:  + 
Address.getnameinfo(sa, 0));
   System.out.println(Local IP:  + 
Address.getip(sa) +
  : + laddr.port);
  -}
  -
  +}
  +
   } catch (Exception e) {
   // Ignore
   e.printStackTrace();
   }
  -
  +
   Socket.timeoutSet(clientSock, 1000);
   Worker worker = new Worker(clientSock, i++,
  this.getClass().getName());
  @@ -183,16 +183,25 @@
   /* Four times size then  created pollset */
   long [] desc = new long[64];
   /* USe 1 second poll timeout */
  -int rv = Poll.poll(serverPollset, 100, desc);
  -for (int n = 0; n  rv; n++) {
  -long clientSock = desc[n*4+1];
  -int  workerId   = (int)desc[n*4+2];
  -System.out.println(Poll flags  + desc[n*4]);
  -remove(clientSock, workerId);
  -Worker worker = new Worker(clientSock, workerId,
  -   
this.getClass().getName());
  -Echo.incThreads();
  -worker.start();
  +int rv = Poll.poll(serverPollset, 100, desc, false);
  +if (rv  0) {
  +for (int n = 0; n  rv; n++) {
  +long clientSock = desc[n*4+1];
  +int  workerId   = (int)desc[n*4+2];
  +System.out.println(Poll flags  + desc[n*4]);
  +remove(clientSock, workerId);
  +Worker worker = new Worker(clientSock, workerId,
  +   
this.getClass().getName());
  +Echo.incThreads();
  +worker.start();
  +}
  +}
  +else {
  +if (Status.APR_STATUS_IS_TIMEUP(-rv))
  +System.out.println(Timeup);
  +else {
  +System.out.println(Error  + (-rv));
  +}
   }
   }
   /* XXX: JFC quick hack
  @@ -294,6 +303,36 @@
   public static void main(String [] args) {
   try {
   Library.initialize(null);
  +long [] inf = new long[16];
  +System.out.println(Info ...);
  +System.out.println(  Native + Library.versionString());
  +System.out.println(  APR+ 
Library.aprVersionString());
  +OS.info(inf);
  +System.out.println(OS Info ...);
  +System.out.println(  Physical   + inf[0]);
  +System.out.println(  Avail  + inf[1]);
  +System.out.println(  Swap   + inf[2]);
  +System.out.println(  Swap free  + inf[3]);
 

cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-18 Thread jfclere
jfclere 2005/04/18 07:06:42

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  Check the return code of bind().
  
  Revision  ChangesPath
  1.8   +5 -2  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Echo.java 16 Apr 2005 17:24:13 -  1.7
  +++ Echo.java 18 Apr 2005 14:06:42 -  1.8
  @@ -83,7 +83,10 @@
   System.out.println(IP:  + Address.getip(sa) +
  : + addr.port);
   }   
  -Socket.bind(serverSock, inetAddress);
  +int rc = Socket.bind(serverSock, inetAddress);
  +if (rc != 0) {
  +  throw(new Exception(Can't create Acceptor:bind failed));
  +}
   Socket.listen(serverSock, 5);
   }
   catch( Exception ex ) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-18 Thread Mladen Turk
[EMAIL PROTECTED] wrote:
  +int rc = Socket.bind(serverSock, inetAddress);
  +if (rc != 0) {
  +  throw(new Exception(Can't create Acceptor:bind failed));
  +}
You can use 'throw(new Exception(Error.strerror(rv)));'
It will return apr_os_error.
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-18 Thread jfclere
jfclere 2005/04/18 08:28:06

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  use Error.strerror(). Thanks Mladen ;-)
  
  Revision  ChangesPath
  1.10  +2 -2  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Echo.java 18 Apr 2005 15:24:01 -  1.9
  +++ Echo.java 18 Apr 2005 15:28:06 -  1.10
  @@ -85,7 +85,7 @@
   }   
   int rc = Socket.bind(serverSock, inetAddress);
   if (rc != 0) {
  -  throw(new Exception(Can't create Acceptor:bind failed));
  +  throw(new Exception(Can't create Acceptor: bind:  + 
Error.strerror(rc)));
   }
   Socket.listen(serverSock, 5);
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-18 Thread jean-frederic clere
Mladen Turk wrote:
[EMAIL PROTECTED] wrote:
  +int rc = Socket.bind(serverSock, inetAddress);
  +if (rc != 0) {
  +  throw(new Exception(Can't create Acceptor:bind 
failed));
  +}

You can use 'throw(new Exception(Error.strerror(rv)));'
It will return apr_os_error.
done.
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-16 Thread jfclere
jfclere 2005/04/16 03:46:55

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  catch the next exception.
  
  Revision  ChangesPath
  1.4   +11 -6 
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Echo.java 15 Apr 2005 14:24:53 -  1.3
  +++ Echo.java 16 Apr 2005 10:46:55 -  1.4
  @@ -64,7 +64,7 @@
   private long serverSock = 0;
   private long inetAddress = 0;
   private long pool = 0;
  -public Acceptor() {
  +public Acceptor() throws Exception {
   try {
   
   pool = Pool.create(Echo.echoPool);
  @@ -80,6 +80,7 @@
   }
   catch( Exception ex ) {
   ex.printStackTrace();
  +throw(new Exception(Can't create Acceptor));
   }
   }
   
  @@ -232,10 +233,14 @@
   {
   int i;
   echoPool = Pool.create(0);
  -echoAcceptor = new Acceptor();
  -echoAcceptor.start();
  -echoPoller = new Poller();
  -echoPoller.start();
  +try {
  +echoAcceptor = new Acceptor();
  +echoAcceptor.start();
  +echoPoller = new Poller();
  +echoPoller.start();
  +} catch (Exception e) {
  +e.printStackTrace();
  +}
   
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-16 Thread mturk
mturk   2005/04/16 08:47:42

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  Display remote connection socket info.
  
  Revision  ChangesPath
  1.5   +15 -2 
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Echo.java 16 Apr 2005 10:46:55 -  1.4
  +++ Echo.java 16 Apr 2005 15:47:42 -  1.5
  @@ -90,6 +90,19 @@
   while (true) {
   long clientSock = Socket.accept(serverSock, pool);
   System.out.println(Accepted id:  +  i);
  +try {
  +long sa = Address.get(Socket.APR_REMOTE, clientSock);
  +Sockaddr addr = new Sockaddr();
  +if (Address.fill(addr, sa)) {
  +System.out.println(Host:  + 
Address.getnameinfo(clientSock, 0));
  +System.out.println(IP:  + Address.getip(sa) +
  +   : + addr.port);
  +}
  +} catch (Exception e) {
  +// Ignore
  +e.printStackTrace();
  +}
  +
   Socket.timeoutSet(clientSock, 1000);
   Worker worker = new Worker(clientSock, i++,
  this.getClass().getName());
  @@ -153,7 +166,7 @@
   long clientSock = Poll.socket(desc[n]);
   int  workerId   = (int)Poll.data(desc[n]);
   System.out.println(Poll flags  + 
Poll.events(desc[n]));
  -remove(clientSock, workerId);
  +remove(clientSock, workerId);
   Worker worker = new Worker(clientSock, workerId,
  
this.getClass().getName());
   Echo.incThreads();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-16 Thread mturk
mturk   2005/04/16 10:24:13

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  Display local socket address too.
  
  Revision  ChangesPath
  1.7   +15 -6 
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Echo.java 16 Apr 2005 16:45:13 -  1.6
  +++ Echo.java 16 Apr 2005 17:24:13 -  1.7
  @@ -101,12 +101,21 @@
   
   try {
   long sa = Address.get(Socket.APR_REMOTE, clientSock);
  -Sockaddr addr = new Sockaddr();
  -if (Address.fill(addr, sa)) {
  -System.out.println(Host:  + 
Address.getnameinfo(sa, 0));
  -System.out.println(IP:  + Address.getip(sa) +
  -   : + addr.port);
  +Sockaddr raddr = new Sockaddr();
  +if (Address.fill(raddr, sa)) {
  +System.out.println(Remote Host:  + 
Address.getnameinfo(sa, 0));
  +System.out.println(Remote IP:  + 
Address.getip(sa) +
  +   : + raddr.port);
   }
  +sa = Address.get(Socket.APR_LOCAL, clientSock);
  +Sockaddr laddr = new Sockaddr();
  +if (Address.fill(laddr, sa)) {
  +System.out.println(Local Host:  + 
laddr.hostname);
  +System.out.println(Local Server:  + 
Address.getnameinfo(sa, 0));
  +System.out.println(Local IP:  + 
Address.getip(sa) +
  +   : + laddr.port);
  +}
  +
   } catch (Exception e) {
   // Ignore
   e.printStackTrace();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-15 Thread jfclere
jfclere 2005/04/15 07:24:53

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  Quick hack to get it compiled.
  
  Revision  ChangesPath
  1.3   +6 -4  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Echo.java 14 Apr 2005 06:46:28 -  1.2
  +++ Echo.java 15 Apr 2005 14:24:53 -  1.3
  @@ -51,8 +51,8 @@
   props.load(is);
   is.close();
   echoAddr = props.getProperty(echo.ip, 127.0.0.1);
  -echoPort = Integer.decode(props.getProperty(echo.port, 23));
  -echoNmax = Integer.decode(props.getProperty(echo.max, 1));
  +echoPort = Integer.decode(props.getProperty(echo.port, 
23)).intValue();
  +echoNmax = Integer.decode(props.getProperty(echo.max, 
1)).intValue();
   }
   catch (Throwable t) {
   ; // Nothing
  @@ -159,15 +159,17 @@
   worker.start();
   }
   }
  +/* XXX: JFC quick hack
   catch(Error err ) {
   if (Status.APR_STATUS_IS_TIMEUP(err.getError())) {
  -/* TODO: deal with timeout */
  +/0 TODO: deal with timeout 0/
   }
   else {
   err.printStackTrace();
   break;
   }
   }
  + */
   catch( Exception ex ) {
   ex.printStackTrace();
   break;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-15 Thread 国炳 陈
???

[EMAIL PROTECTED] wrote:jfclere 2005/04/15 07:24:53

Modified: jni/examples/org/apache/tomcat/jni Echo.java
Log:
Quick hack to get it compiled.

Revision Changes Path
1.3 +6 -4 jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java

Index: Echo.java
===
RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Echo.java 14 Apr 2005 06:46:28 - 1.2
+++ Echo.java 15 Apr 2005 14:24:53 - 1.3
@@ -51,8 +51,8 @@
props.load(is);
is.close();
echoAddr = props.getProperty(echo.ip, 127.0.0.1);
- echoPort = Integer.decode(props.getProperty(echo.port, 23));
- echoNmax = Integer.decode(props.getProperty(echo.max, 1));
+ echoPort = Integer.decode(props.getProperty(echo.port, 23)).intValue();
+ echoNmax = Integer.decode(props.getProperty(echo.max, 1)).intValue();
}
catch (Throwable t) {
; // Nothing
@@ -159,15 +159,17 @@
worker.start();
}
}
+ /* XXX: JFC quick hack
catch(Error err ) {
if (Status.APR_STATUS_IS_TIMEUP(err.getError())) {
- /* TODO: deal with timeout */
+ /0 TODO: deal with timeout 0/
}
else {
err.printStackTrace();
break;
}
}
+ */
catch( Exception ex ) {
ex.printStackTrace();
break;




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




!
\\\|///
\\ - - //
( @ @ )
 oOOo- (_)-oOOo
:gzlongzhijian 
QQ(OICQ) 40831127 Q 
:[EMAIL PROTECTED] 
:http://www.gzlzj.com 
401 
:510630 :020-33629058 
 
 
 
 
 Oooo 
 oooO ( )
( ) ) /
\ ( (_/
\_)



-
Do You Yahoo!?
150MP3

1G1000

cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java

2005-04-14 Thread mturk
mturk   2005/04/13 23:46:28

  Modified:jni/examples/org/apache/tomcat/jni Echo.java
  Log:
  Update Examples for a slightly changed api.
  
  Revision  ChangesPath
  1.2   +10 -8 
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Echo.java 5 Feb 2005 12:34:47 -   1.1
  +++ Echo.java 14 Apr 2005 06:46:28 -  1.2
  @@ -89,6 +89,7 @@
   while (true) {
   long clientSock = Socket.accept(serverSock, pool);
   System.out.println(Accepted id:  +  i);
  +Socket.timeoutSet(clientSock, 1000);
   Worker worker = new Worker(clientSock, i++,
  this.getClass().getName());
   Echo.incThreads();
  @@ -110,7 +111,7 @@
   try {
   
   pool = Pool.create(Echo.echoPool);
  -serverPollset = Poll.create(16, pool, 0);
  +serverPollset = Poll.create(16, pool, 0, 1000);
   }
   catch( Exception ex ) {
   ex.printStackTrace();
  @@ -119,7 +120,7 @@
   
   public void add(long socket, int workerId) {
   int rv = Poll.add(serverPollset, socket, workerId,
  -  Poll.APR_POLLIN, 0);
  +  Poll.APR_POLLIN);
   if (rv == Status.APR_SUCCESS) {
   System.out.println(Added worker  + workerId +  to 
pollset);
   nsocks++;
  @@ -150,7 +151,8 @@
   for (int n = 0; n  rv; n++) {
   long clientSock = Poll.socket(desc[n]);
   int  workerId   = (int)Poll.data(desc[n]);
  -remove(clientSock, workerId);
  +System.out.println(Poll flags  + 
Poll.events(desc[n]));
  +remove(clientSock, workerId);
   Worker worker = new Worker(clientSock, workerId,
  
this.getClass().getName());
   Echo.incThreads();
  @@ -188,10 +190,10 @@
   public void run() {
   boolean doClose = false;
   try {
  -Socket.send(clientSock, wellcomeMsg, wellcomeMsg.length);
  +Socket.send(clientSock, wellcomeMsg, 0, wellcomeMsg.length);
   /* Do a blocking read byte at a time */
   byte [] buf = new byte[1];
  -while (Socket.recv(clientSock, buf, 1) == 1) {
  +while (Socket.recv(clientSock, buf, 0, 1) == 1) {
   if (buf[0] == '\n')
   break;
   else if (buf[0] == 'Q') {
  @@ -202,7 +204,7 @@
   if (doClose) {
   try {
   byte [] msg = (Bye from worker:  + workerId + 
\r\n).getBytes();
  -Socket.send(clientSock, msg, msg.length);
  +Socket.send(clientSock, msg, 0, msg.length);
   } catch(Exception e) { }
   
   Socket.close(clientSock);
  @@ -210,7 +212,7 @@
   else {
   try {
   byte [] msg = (Recycling worker:  + workerId + 
\r\n).getBytes();
  -Socket.send(clientSock, msg, msg.length);
  +Socket.send(clientSock, msg, 0, msg.length);
   } catch(Exception e) { }
   /* Put the socket to the keep-alive poll */
   Echo.echoPoller.add(clientSock, workerId);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java Echo.properties

2005-02-05 Thread mturk
mturk   2005/02/05 04:34:47

  Added:   jni/examples/org/apache/tomcat/jni Echo.java Echo.properties
  Log:
  Add simpe Echo server with pollset for nonblocking
  call after the first message is read.
  
  Revision  ChangesPath
  1.1  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  /*
   *  Copyright 1999-2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the License);
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *  http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an AS IS BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.tomcat.jni;
  
  import java.util.Properties;
  
  import java.io.*;
  import java.net.*;
  import java.lang.*;
  
  /** Echo server example
   *
   * @author Mladen Turk
   * @version $Revision: 1.1 $, $Date: 2005/02/05 12:34:47 $
   */
  
  public class Echo {
  
  public static String echoEcho = null;
  public static String echoAddr = null;
  public static int echoPort= 0;
  public static int echoNmax= 0;
  public static int echoNrun= 0;
  public static long echoPool   = 0;
  
  private static Poller echoPoller = null;
  private static Acceptor echoAcceptor = null;
  
  private static Object threadLock = new Object();
  
  static {
  
  try {
  InputStream is = Echo.class.getResourceAsStream
  (/org/apache/tomcat/jni/Echo.properties);
  Properties props = new Properties();
  props.load(is);
  is.close();
  echoAddr = props.getProperty(echo.ip, 127.0.0.1);
  echoPort = Integer.decode(props.getProperty(echo.port, 23));
  echoNmax = Integer.decode(props.getProperty(echo.max, 1));
  }
  catch (Throwable t) {
  ; // Nothing
  }
  }
  
  /* Acceptor thread. Listens for new connections */
  private class Acceptor extends Thread {
  private long serverSock = 0;
  private long inetAddress = 0;
  private long pool = 0;
  public Acceptor() {
  try {
  
  pool = Pool.create(Echo.echoPool);
  System.out.println(Accepting:  +  Echo.echoAddr + : +
 Echo.echoPort);
  inetAddress = Address.info(Echo.echoAddr, Socket.APR_INET,
 Echo.echoPort, 0,
 pool);
  serverSock = Socket.create(Socket.APR_INET, 
Socket.SOCK_STREAM,
 Socket.APR_PROTO_TCP, pool);
  Socket.bind(serverSock, inetAddress);
  Socket.listen(serverSock, 5);
  }
  catch( Exception ex ) {
  ex.printStackTrace();
  }
  }
  
  public void run() {
  int i = 0;
  try {
  while (true) {
  long clientSock = Socket.accept(serverSock, pool);
  System.out.println(Accepted id:  +  i);
  Worker worker = new Worker(clientSock, i++,
 this.getClass().getName());
  Echo.incThreads();
  worker.start();
  }
  }
  catch( Exception ex ) {
  ex.printStackTrace();
  }
  }
  }
  
  /* Poller thread. Listens for new recycled connections */
  private class Poller extends Thread {
  private long serverPollset = 0;
  private long pool = 0;
  private int nsocks = 0;
  public Poller() {
  try {
  
  pool = Pool.create(Echo.echoPool);
  serverPollset = Poll.create(16, pool, 0);
  }
  catch( Exception ex ) {
  ex.printStackTrace();
  }
  }
  
  public void add(long socket, int workerId) {
  int rv = Poll.add(serverPollset, socket, workerId,
Poll.APR_POLLIN, 0);
  if (rv == Status.APR_SUCCESS) {
  System.out.println(Added worker  + workerId +  to 
pollset);
  nsocks++;
  }
  }
  
  public void remove(long socket, int workerId) {
  int rv = Poll.remove(serverPollset, socket);
  if