tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni Echo.java
Date Thu, 14 Apr 2005 06:46:28 GMT
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  Changes    Path
  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 -0000	1.1
  +++ Echo.java	14 Apr 2005 06:46:28 -0000	1.2
  @@ -89,6 +89,7 @@
                   while (true) {
                       long clientSock = Socket.accept(serverSock, pool);
                       System.out.println("Accepted id: " +  i);
  +                    Socket.timeoutSet(clientSock, 10000000);
                       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, 10000000);
               }
               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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message