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/native/src info.c network.c
Date Sat, 16 Apr 2005 16:45:13 GMT
mturk       2005/04/16 09:45:13

  Modified:    jni/examples/org/apache/tomcat/jni Echo.java
               jni/java/org/apache/tomcat/jni Address.java
               jni/native/src info.c network.c
  Log:
  Add Address.getInfo that creates the Sockaddr object.
  
  Revision  Changes    Path
  1.6       +12 -3     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Echo.java	16 Apr 2005 15:47:42 -0000	1.5
  +++ Echo.java	16 Apr 2005 16:45:13 -0000	1.6
  @@ -75,6 +75,14 @@
                                              pool);
                   serverSock = Socket.create(Socket.APR_INET, Socket.SOCK_STREAM,
                                              Socket.APR_PROTO_TCP, pool);
  +                long sa = Address.get(Socket.APR_LOCAL, serverSock);
  +                Sockaddr addr = new Sockaddr();
  +                if (Address.fill(addr, sa)) {
  +                    System.out.println("Host: " + addr.hostname);
  +                    System.out.println("Server: " + addr.servname);
  +                    System.out.println("IP: " + Address.getip(sa) +
  +                                       ":" + addr.port);
  +                }                                           
                   Socket.bind(serverSock, inetAddress);
                   Socket.listen(serverSock, 5);
               }
  @@ -90,11 +98,12 @@
                   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("Host: " + Address.getnameinfo(sa, 0));
                               System.out.println("IP: " + Address.getip(sa) +
                                                  ":" + addr.port);
                           }
  @@ -102,7 +111,7 @@
                           // Ignore
                           e.printStackTrace();
                       }
  -
  +                    
                       Socket.timeoutSet(clientSock, 10000000);
                       Worker worker = new Worker(clientSock, i++,
                                                  this.getClass().getName());
  
  
  
  1.4       +8 -2      jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Address.java
  
  Index: Address.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Address.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Address.java	16 Apr 2005 15:46:36 -0000	1.3
  +++ Address.java	16 Apr 2005 16:45:13 -0000	1.4
  @@ -26,13 +26,19 @@
   
       static public String APR_ANYADDR = "0.0.0.0";
       /**
  -     * Fill the Address class from apr_sockaddr_t
  +     * Fill the Sockaddr class from apr_sockaddr_t
        * @param info Sockaddr class to fill
        * @param sa Structure pointer
        */
       public static native boolean fill(Sockaddr info, long sa);
   
       /**
  +     * Create the Sockaddr object from apr_sockaddr_t
  +     * @param sa Structure pointer
  +     */
  +    public static native Sockaddr getInfo(long sa);
  +
  +    /**
        * Create apr_sockaddr_t from hostname, address family, and port.
        * @param hostname The hostname or numeric address string to resolve/parse, or
        *               NULL to build an address that corresponds to 0.0.0.0 or ::
  
  
  
  1.4       +29 -0     jakarta-tomcat-connectors/jni/native/src/info.c
  
  Index: info.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/info.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- info.c	16 Apr 2005 15:46:36 -0000	1.3
  +++ info.c	16 Apr 2005 16:45:13 -0000	1.4
  @@ -291,3 +291,32 @@
       }
       return rv;
   }
  +
  +TCN_IMPLEMENT_CALL(jobject, Address, getInfo)(TCN_STDARGS, jlong info)
  +{
  +    apr_sockaddr_t *i = J2P(info, apr_sockaddr_t *);
  +    jclass aprSockaddrClass;
  +    jmethodID constructorID = 0;
  +    jobject sockaddrObj = NULL;
  +
  +    UNREFERENCED(o);
  +
  +    aprSockaddrClass = (*e)->FindClass(e, TCN_AINFO_CLASS);
  +    if (aprSockaddrClass == NULL)
  +        return NULL;
  +
  +    /* Find the constructor ID */
  +    constructorID = (*e)->GetMethodID(e, aprSockaddrClass,
  +                                      "<init>", "()V");
  +    if (constructorID == NULL)
  +        goto cleanup;
  +    /* Create the APR Error object */
  +    sockaddrObj = (*e)->NewObject(e, aprSockaddrClass, constructorID);
  +    if (sockaddrObj == NULL)
  +        goto cleanup;
  +    fill_ainfo(e, sockaddrObj, i);
  +cleanup:
  +    (*e)->DeleteLocalRef(e, aprSockaddrClass);
  +
  +    return sockaddrObj;
  +}
  
  
  
  1.11      +2 -2      jakarta-tomcat-connectors/jni/native/src/network.c
  
  Index: network.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/network.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- network.c	16 Apr 2005 15:46:36 -0000	1.10
  +++ network.c	16 Apr 2005 16:45:13 -0000	1.11
  @@ -85,11 +85,11 @@
                                            jlong sock)
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
  -    apr_sockaddr_t *sa;
  +    apr_sockaddr_t *sa = NULL;
   
       UNREFERENCED(o);
       TCN_THROW_IF_ERR(apr_socket_addr_get(&sa,
  -                                    which, s), sa);
  +                                    (apr_interface_e)which, s), sa);
   cleanup:
       return P2J(sa);
   }
  
  
  

---------------------------------------------------------------------
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