commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1099803 - in /commons/sandbox/runtime/trunk/src/main: native/shared/netserv.c test/org/apache/commons/runtime/TestAddress.java
Date Thu, 05 May 2011 13:49:56 GMT
Author: mturk
Date: Thu May  5 13:49:56 2011
New Revision: 1099803

URL: http://svn.apache.org/viewvc?rev=1099803&view=rev
Log:
Tranlate to network byte order

Modified:
    commons/sandbox/runtime/trunk/src/main/native/shared/netserv.c
    commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/netserv.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/netserv.c?rev=1099803&r1=1099802&r2=1099803&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/netserv.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/netserv.c Thu May  5 13:49:56 2011
@@ -87,12 +87,10 @@ ACR_NET_EXPORT(jint, Service, getservbyn
         if ((se = getservbyname(J2S(name), J2S(proto))) == 0)
             rc = ACR_GET_NETOS_ERROR();
         else {
-            printf("Found1 http %d\n", (int)se->s_port);
-            fflush(stdout);
             SET_IFIELD_S(0000, obj, se->s_name);
             SET_IFIELD_S(0001, obj, se->s_proto);
             SET_IFIELD_O(0002, obj, AcrNewStringArrayA(env, (const char **)se->s_aliases));
-            SET_IFIELD_I(0003, obj, se->s_port);
+            SET_IFIELD_I(0003, obj, ntohs(se->s_port));
         }
     } DONE_WITH_STR(proto);
     } DONE_WITH_STR(name);
@@ -106,18 +104,13 @@ ACR_NET_EXPORT(jint, Service, getservbyp
     struct servent *se;
 
     WITH_CSTR(proto) {
-        if ((se = getservbyport(port, J2S(proto))) == 0) {
+        if ((se = getservbyport(htons(port), J2S(proto))) == 0)
             rc = ACR_GET_NETOS_ERROR();
-            printf("Failed for port %d %d %s\n", port, rc, J2S(proto));
-            fflush(stdout);
-        }
         else {
-            printf("Found2 http %s for %d  %s\n", se->s_name, port, J2S(proto));
-            fflush(stdout);
             SET_IFIELD_S(0000, obj, se->s_name);
             SET_IFIELD_S(0001, obj, se->s_proto);
             SET_IFIELD_O(0002, obj, AcrNewStringArrayA(env, (const char **)se->s_aliases));
-            SET_IFIELD_I(0003, obj, se->s_port);
+            SET_IFIELD_I(0003, obj, ntohs(se->s_port));
         }
     } DONE_WITH_STR(proto);
 

Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java?rev=1099803&r1=1099802&r2=1099803&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestAddress.java
Thu May  5 13:49:56 2011
@@ -54,11 +54,8 @@ public class TestAddress extends Assert
         throws IOException
     {
         Service s1 = new Service("http", "tcp");
-        System.out.println("Port is " + s1.getPort());
-//        assertEquals(s1.getPort(), 80);
-        Service s2 = new Service(80);
-        System.out.println("Name is " + s2.getName());
-        System.out.println("Port is " + s2.getPort());
-//        assertEquals(s2.getName(), "http");
+        assertEquals(s1.getPort(), 80);
+        Service s2 = new Service(21);
+        assertEquals(s2.getName(), "ftp");
     }
 }



Mime
View raw message