You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2008/11/22 22:16:22 UTC

svn commit: r719920 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main: java/org/apache/harmony/luni/platform/ native/luni/shared/ native/luni/unix/ native/luni/windows/

Author: tellison
Date: Sat Nov 22 13:16:22 2008
New Revision: 719920

URL: http://svn.apache.org/viewvc?rev=719920&view=rev
Log:
More tidy-up in OSNetworkSystem.  Method sorting, renaming, formatting.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java?rev=719920&r1=719919&r2=719920&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java Sat Nov 22 13:16:22 2008
@@ -39,11 +39,6 @@
 
     private static OSNetworkSystem singleton = new OSNetworkSystem();
 
-    // Can not be instantiated.
-    private OSNetworkSystem() {
-        super();
-    }
-
     /**
      * Answers the unique instance of the OSNetworkSystem.
      * 
@@ -53,40 +48,19 @@
         return singleton;
     }
 
-    public native void createSocket(FileDescriptor fd, boolean preferIPv4Stack)
-            throws IOException;
-
-    public native void createDatagramSocket(FileDescriptor fd,
-            boolean preferIPv4Stack) throws SocketException;
-
-    public native int read(FileDescriptor fd, byte[] data, int offset,
-            int count, int timeout) throws IOException;
-
-    public native int readDirect(FileDescriptor fd, long address, int count,
-            int timeout) throws IOException;
-
-    public native int write(FileDescriptor fd, byte[] data, int offset,
-            int count) throws IOException;
+    // Can not be instantiated.
+    private OSNetworkSystem() {
+        super();
+    }
 
-    public native int writeDirect(FileDescriptor fd, long address, int count)
-            throws IOException;
+    public native void accept(FileDescriptor fdServer, SocketImpl newSocket,
+            FileDescriptor fdnewSocket, int timeout) throws IOException;
 
-    public native void setNonBlocking(FileDescriptor fd, boolean block)
+    public native void acceptStreamSocket(FileDescriptor fdServer,
+            SocketImpl newSocket, FileDescriptor fdnewSocket, int timeout)
             throws IOException;
 
-    public native void connectDatagram(FileDescriptor fd, int port,
-            int trafficClass, InetAddress inetAddress) throws SocketException;
-
-    public native int connect(FileDescriptor fd, int trafficClass,
-            InetAddress inetAddress, int port) throws IOException;
-
-    public native int connectWithTimeout(FileDescriptor fd, int timeout,
-            int trafficClass, InetAddress inetAddress, int port, int step,
-            Long context) throws IOException;
-
-    public native void connectStreamWithTimeoutSocket(FileDescriptor aFD, int aport,
-            int timeout, int trafficClass, InetAddress inetAddress)
-            throws IOException;
+    public native int availableStream(FileDescriptor fd) throws SocketException;
 
     public native void bind(FileDescriptor aFD, int port,
             InetAddress inetAddress) throws SocketException;
@@ -103,113 +77,135 @@
      * @param inetAddress
      *            address to connect to.
      * @return if bind successful
-     * @exception SocketException
-     *                thrown if bind operation fails
+     * @throws SocketException
+     *             thrown if bind operation fails
      */
-    public native boolean bind2(FileDescriptor fd, int port, boolean bindToDevice,
-            InetAddress inetAddress) throws SocketException;
+    public native boolean bind2(FileDescriptor fd, int port,
+            boolean bindToDevice, InetAddress inetAddress)
+            throws SocketException;
 
-    public native void accept(FileDescriptor fdServer, SocketImpl newSocket,
-            FileDescriptor fdnewSocket, int timeout) throws IOException;
+    public native int connect(FileDescriptor fd, int trafficClass,
+            InetAddress inetAddress, int port) throws IOException;
+
+    public native void connectDatagram(FileDescriptor fd, int port,
+            int trafficClass, InetAddress inetAddress) throws SocketException;
+
+    public native void connectStreamWithTimeoutSocket(FileDescriptor aFD,
+            int aport, int timeout, int trafficClass, InetAddress inetAddress)
+            throws IOException;
+
+    public native int connectWithTimeout(FileDescriptor fd, int timeout,
+            int trafficClass, InetAddress inetAddress, int port, int step,
+            Long context) throws IOException;
+
+    public native void createDatagramSocket(FileDescriptor fd,
+            boolean preferIPv4Stack) throws SocketException;
 
     /**
-     * Send the <code>data</code> to the nominated target <code>address</code>
-     * and <code>port</code>. These values are derived from the DatagramPacket
-     * to reduce the field calls within JNI.
+     * Answer the result of attempting to create a multicast socket in the IP
+     * stack. Any special options required for server sockets will be set by
+     * this method.
      * 
-     * @param fd
+     * @param aFD
      *            the socket FileDescriptor
-     * @param data
-     *            the data buffer of the packet
-     * @param offset
-     *            the offset in the data buffer
-     * @param length
-     *            the length of the data buffer in the packet
-     * @param port
-     *            the target host port
-     * @param bindToDevice
-     *            if bind to device
-     * @param trafficClass
-     *            the traffic class to be used when the datagram is sent
-     * @param inetAddress
-     *            address to connect to.
-     * @return number of data send
+     * @param preferIPv4Stack
+     *            if use IPV4
+     * @throws SocketException
+     *             if an error occurs while creating the socket
+     */
+    public native void createMulticastSocket(FileDescriptor aFD,
+            boolean preferIPv4Stack) throws SocketException;
+
+    /**
+     * Answer the result of attempting to create a server stream socket in the
+     * IP stack. Any special options required for server sockets will be set by
+     * this method.
      * 
-     * @exception IOException
-     *                upon an read error or timeout
+     * @param aFD
+     *            the socket FileDescriptor @param preferIPv4Stack if use IPV4
+     * @throws SocketException
+     *             if an error occurs while creating the socket
      */
-    public native int sendDatagram(FileDescriptor fd, byte[] data, int offset,
-            int length, int port, boolean bindToDevice, int trafficClass,
-            InetAddress inetAddress) throws IOException;
+    public native void createServerStreamSocket(FileDescriptor aFD,
+            boolean preferIPv4Stack) throws SocketException;
 
-    public native int sendDatagramDirect(FileDescriptor fd, long address,
-            int offset, int length, int port, boolean bindToDevice,
-            int trafficClass, InetAddress inetAddress) throws IOException;
+    public native void createSocket(FileDescriptor fd, boolean preferIPv4Stack)
+            throws IOException;
 
-    public native int sendDatagram2(FileDescriptor fd, byte[] data, int offset,
-            int length, int port, InetAddress inetAddress) throws IOException;
+    public native void createStreamSocket(FileDescriptor fd,
+            boolean preferIPv4Stack) throws SocketException;
 
     /**
-     * Receive data on the socket into the specified buffer. The packet fields
-     * <code>data</code> & <code>length</code> are passed in addition to
-     * <code>packet</code> to eliminate the JNI field access calls.
+     * Disconnect the socket to a port and address
      * 
      * @param fd
-     *            the socket FileDescriptor
-     * @param packet
-     *            the DatagramPacket to receive into
-     * @param data
-     *            the data buffer of the packet
-     * @param offset
-     *            the offset in the data buffer
-     * @param length
-     *            the length of the data buffer in the packet
-     * @param receiveTimeout
-     *            the maximum length of time the socket should block, reading
-     * @param peek
-     *            indicates to peek at the data
-     * @return number of data received
-     * @exception IOException
-     *                upon an read error or timeout
+     *            the FileDescriptor associated with the socket
+     * 
+     * @throws SocketException
+     *             if the disconnect fails
      */
-    public native int receiveDatagram(FileDescriptor fd, DatagramPacket packet,
-            byte[] data, int offset, int length, int receiveTimeout,
-            boolean peek) throws IOException;
+    public native void disconnectDatagram(FileDescriptor fd)
+            throws SocketException;
 
-    public native int receiveDatagramDirect(FileDescriptor fd, DatagramPacket packet,
-            long address, int offset, int length, int receiveTimeout,
-            boolean peek) throws IOException;
+    public native InetAddress getHostByAddr(byte[] addr)
+            throws UnknownHostException;
+
+    public native InetAddress getHostByName(String addr,
+            boolean preferIPv6Addresses) throws UnknownHostException;
+
+    public native int getSocketFlags();
+
+    public native InetAddress getSocketLocalAddress(FileDescriptor fd,
+            boolean preferIPv6Addresses);
 
     /**
-     * Recieve data on the connected socket into the specified buffer. The
-     * packet fields <code>data</code> and <code>length</code> are passed in
-     * addition to <code>packet</code> to eliminate the JNI field access calls.
+     * Query the IP stack for the local port to which this socket is bound.
+     * 
+     * @param aFD
+     *            the socket descriptor
+     * @param preferIPv6Addresses
+     *            address preference for nodes that support both IPv4 and IPv6
+     * @return the local port to which the socket is bound
+     */
+    public native int getSocketLocalPort(FileDescriptor aFD,
+            boolean preferIPv6Addresses);
+
+    /**
+     * Query the IP stack for the nominated socket option.
      * 
      * @param fd
-     *            the socket FileDescriptor
-     * @param packet
-     *            the DatagramPacket to receive into
-     * @param data
-     *            the data buffer of the packet
-     * @param offset
-     *            the offset in the data buffer
-     * @param length
-     *            the length of the data buffer in the packet
-     * @param receiveTimeout
-     *            the maximum length of time the socket should block, reading
-     * @param peek
-     *            indicates to peek at the data
-     * @return number of data received
-     * @exception IOException
-     *                upon an read error or timeout
+     *            the socket descriptor
+     * @param opt
+     *            the socket option type
+     * @return the nominated socket option value
+     * @throws SocketException
+     *             if the option is invalid
      */
-    public native int recvConnectedDatagram(FileDescriptor fd,
-            DatagramPacket packet, byte[] data, int offset, int length,
-            int receiveTimeout, boolean peek) throws IOException;
+    public native Object getSocketOption(FileDescriptor fd, int opt)
+            throws SocketException;
 
-    public native int recvConnectedDatagramDirect(FileDescriptor fd,
-            DatagramPacket packet, long address, int offset, int length,
-            int receiveTimeout, boolean peek) throws IOException;
+    public native Channel inheritedChannel();
+
+    public boolean isReachableByICMP(final InetAddress dest,
+            InetAddress source, final int ttl, final int timeout) {
+        return INETADDR_REACHABLE == isReachableByICMPImpl(dest, source, ttl,
+                timeout);
+    }
+
+    private native int isReachableByICMPImpl(InetAddress addr,
+            InetAddress local, int ttl, int timeout);
+
+    public native void listenStreamSocket(FileDescriptor aFD, int backlog)
+            throws SocketException;
+
+    public void oneTimeInitialization(boolean jcl_supports_ipv6) {
+        if (!isNetworkInited) {
+            oneTimeInitializationImpl(jcl_supports_ipv6);
+            isNetworkInited = true;
+        }
+    }
+
+    private native void oneTimeInitializationImpl(boolean jcl_supports_ipv6);
 
     /**
      * Peek on the socket, update <code>sender</code> address and answer the
@@ -223,74 +219,48 @@
      *            the maximum length of time the socket should block, reading
      * @return the sender port
      * 
-     * @exception IOException
-     *                upon an read error or timeout
+     * @throws IOException
+     *             upon an read error or timeout
      */
     public native int peekDatagram(FileDescriptor fd, InetAddress sender,
             int receiveTimeout) throws IOException;
 
+    public native int read(FileDescriptor fd, byte[] data, int offset,
+            int count, int timeout) throws IOException;
+
+    public native int readDirect(FileDescriptor fd, long address, int count,
+            int timeout) throws IOException;
+
     /**
-     * Send the <code>data</code> to the address and port to which the was
-     * connected and <code>port</code>.
+     * Receive data on the socket into the specified buffer. The packet fields
+     * <code>data</code> & <code>length</code> are passed in addition to
+     * <code>packet</code> to eliminate the JNI field access calls.
      * 
      * @param fd
      *            the socket FileDescriptor
+     * @param packet
+     *            the DatagramPacket to receive into
      * @param data
      *            the data buffer of the packet
      * @param offset
      *            the offset in the data buffer
      * @param length
      *            the length of the data buffer in the packet
-     * @param bindToDevice
-     *            not used, current kept in case needed as was the case for
-     *            sendDatagramImpl
-     * @return number of data send
+     * @param receiveTimeout
+     *            the maximum length of time the socket should block, reading
+     * @param peek
+     *            indicates to peek at the data
+     * @return number of data received
      * @throws IOException
      *             upon an read error or timeout
      */
-    public native int sendConnectedDatagram(FileDescriptor fd, byte[] data,
-            int offset, int length, boolean bindToDevice) throws IOException;
-
-    public native int sendConnectedDatagramDirect(FileDescriptor fd, long address,
-            int offset, int length, boolean bindToDevice) throws IOException;
-
-    /**
-     * Disconnect the socket to a port and address
-     * 
-     * @param fd
-     *            the FileDescriptor associated with the socket
-     * 
-     * @exception SocketException
-     *                if the disconnect fails
-     */
-    public native void disconnectDatagram(FileDescriptor fd) throws SocketException;
-
-    /**
-     * Answer the result of attempting to create a multicast socket in the IP
-     * stack. Any special options required for server sockets will be set by
-     * this method.
-     * 
-     * @param aFD
-     *            the socket FileDescriptor
-     *            @param preferIPv4Stack if use IPV4
-     * @exception SocketException
-     *                if an error occurs while creating the socket
-     */
-    public native void createMulticastSocket(FileDescriptor aFD,
-            boolean preferIPv4Stack) throws SocketException;
+    public native int receiveDatagram(FileDescriptor fd, DatagramPacket packet,
+            byte[] data, int offset, int length, int receiveTimeout,
+            boolean peek) throws IOException;
 
-    /**
-     * Answer the result of attempting to create a server stream socket in the
-     * IP stack. Any special options required for server sockets will be set by
-     * this method.
-     * 
-     * @param aFD
-     *            the socket FileDescriptor @param preferIPv4Stack if use IPV4
-     * @exception SocketException
-     *                if an error occurs while creating the socket
-     */
-    public native void createServerStreamSocket(FileDescriptor aFD,
-            boolean preferIPv4Stack) throws SocketException;
+    public native int receiveDatagramDirect(FileDescriptor fd,
+            DatagramPacket packet, long address, int offset, int length,
+            int receiveTimeout, boolean peek) throws IOException;
 
     /**
      * Receive at most <code>count</code> bytes into the buffer
@@ -311,52 +281,39 @@
      * @throws SocketException
      *             if an error occurs while reading
      */
-    public native int receiveStream(FileDescriptor aFD, byte[] data, int offset,
-            int count, int timeout) throws IOException;
+    public native int receiveStream(FileDescriptor aFD, byte[] data,
+            int offset, int count, int timeout) throws IOException;
 
     /**
-     * Send <code>count</code> bytes from the buffer <code>data</code> at the
-     * <code>offset</code>, on the socket.
+     * Recieve data on the connected socket into the specified buffer. The
+     * packet fields <code>data</code> and <code>length</code> are passed in
+     * addition to <code>packet</code> to eliminate the JNI field access calls.
      * 
      * @param fd
-     * 
+     *            the socket FileDescriptor
+     * @param packet
+     *            the DatagramPacket to receive into
      * @param data
-     *            the send buffer @param offset the offset into the buffer
-     * @param count
-     *            the number of bytes to receive
-     * @return the actual number of bytes sent
+     *            the data buffer of the packet
+     * @param offset
+     *            the offset in the data buffer
+     * @param length
+     *            the length of the data buffer in the packet
+     * @param receiveTimeout
+     *            the maximum length of time the socket should block, reading
+     * @param peek
+     *            indicates to peek at the data
+     * @return number of data received
      * @throws IOException
-     * @throws SocketException
-     *             if an error occurs while writing
+     *             upon an read error or timeout
      */
-    public native int sendStream(FileDescriptor fd, byte[] data, int offset,
-            int count) throws IOException;
-
-    public native void shutdownInput(FileDescriptor fd) throws IOException;
-
-    public native void shutdownOutput(FileDescriptor fd) throws IOException;
-
-    public native boolean supportsUrgentData(FileDescriptor fd);
-
-    public native void sendUrgentData(FileDescriptor fd, byte value);
-
-    public native int availableStream(FileDescriptor fd) throws SocketException;
-
-    public native void acceptStreamSocket(FileDescriptor fdServer,
-            SocketImpl newSocket, FileDescriptor fdnewSocket, int timeout)
-            throws IOException;
-
-    public native void createStreamSocket(FileDescriptor fd, boolean preferIPv4Stack)
-            throws SocketException;
-
-    public native void listenStreamSocket(FileDescriptor aFD, int backlog)
-            throws SocketException;
+    public native int recvConnectedDatagram(FileDescriptor fd,
+            DatagramPacket packet, byte[] data, int offset, int length,
+            int receiveTimeout, boolean peek) throws IOException;
 
-    public boolean isReachableByICMP(final InetAddress dest,
-            InetAddress source, final int ttl, final int timeout) {
-        return INETADDR_REACHABLE == isReachableByICMPImpl(dest, source, ttl,
-                timeout);
-    }
+    public native int recvConnectedDatagramDirect(FileDescriptor fd,
+            DatagramPacket packet, long address, int offset, int length,
+            int receiveTimeout, boolean peek) throws IOException;
 
     /**
      * Select the given file descriptors for read and write operations.
@@ -406,54 +363,97 @@
         throw new SocketException();
     }
 
-    /*
-     * Used to check if the file descriptor arrays are valid before passing them
-     * into the select native call.
+    private native int selectImpl(FileDescriptor[] readfd,
+            FileDescriptor[] writefd, int cread, int cwirte, int[] flags,
+            long timeout);
+
+    /**
+     * Send the <code>data</code> to the address and port to which the was
+     * connected and <code>port</code>.
+     * 
+     * @param fd
+     *            the socket FileDescriptor
+     * @param data
+     *            the data buffer of the packet
+     * @param offset
+     *            the offset in the data buffer
+     * @param length
+     *            the length of the data buffer in the packet
+     * @param bindToDevice
+     *            not used, current kept in case needed as was the case for
+     *            sendDatagramImpl
+     * @return number of data send
+     * @throws IOException
+     *             upon an read error or timeout
      */
-    private boolean validateFDs(FileDescriptor[] readFDs,
-            FileDescriptor[] writeFDs) {
-        for (FileDescriptor fd : readFDs) {
-            // Also checks fd not null
-            if (!fd.valid()) {
-                return false;
-            }
-        }
-        for (FileDescriptor fd : writeFDs) {
-            if (!fd.valid()) {
-                return false;
-            }
-        }
-        return true;
-    }
+    public native int sendConnectedDatagram(FileDescriptor fd, byte[] data,
+            int offset, int length, boolean bindToDevice) throws IOException;
 
-    public native InetAddress getSocketLocalAddress(FileDescriptor fd,
-            boolean preferIPv6Addresses);
+    public native int sendConnectedDatagramDirect(FileDescriptor fd,
+            long address, int offset, int length, boolean bindToDevice)
+            throws IOException;
 
     /**
-     * Query the IP stack for the local port to which this socket is bound.
+     * Send the <code>data</code> to the nominated target <code>address</code>
+     * and <code>port</code>. These values are derived from the DatagramPacket
+     * to reduce the field calls within JNI.
      * 
-     * @param aFD
-     *            the socket descriptor
-     * @param preferIPv6Addresses
-     *            address preference for nodes that support both IPv4 and IPv6
-     * @return the local port to which the socket is bound
+     * @param fd
+     *            the socket FileDescriptor
+     * @param data
+     *            the data buffer of the packet
+     * @param offset
+     *            the offset in the data buffer
+     * @param length
+     *            the length of the data buffer in the packet
+     * @param port
+     *            the target host port
+     * @param bindToDevice
+     *            if bind to device
+     * @param trafficClass
+     *            the traffic class to be used when the datagram is sent
+     * @param inetAddress
+     *            address to connect to.
+     * @return number of data send
+     * 
+     * @throws IOException
+     *             upon an read error or timeout
      */
-    public native int getSocketLocalPort(FileDescriptor aFD,
-            boolean preferIPv6Addresses);
+    public native int sendDatagram(FileDescriptor fd, byte[] data, int offset,
+            int length, int port, boolean bindToDevice, int trafficClass,
+            InetAddress inetAddress) throws IOException;
+
+    public native int sendDatagram2(FileDescriptor fd, byte[] data, int offset,
+            int length, int port, InetAddress inetAddress) throws IOException;
+
+    public native int sendDatagramDirect(FileDescriptor fd, long address,
+            int offset, int length, int port, boolean bindToDevice,
+            int trafficClass, InetAddress inetAddress) throws IOException;
 
     /**
-     * Query the IP stack for the nominated socket option.
+     * Send <code>count</code> bytes from the buffer <code>data</code> at the
+     * <code>offset</code>, on the socket.
      * 
      * @param fd
-     *            the socket descriptor
-     * @param opt
-     *            the socket option type
-     * @return the nominated socket option value
+     * 
+     * @param data
+     *            the send buffer @param offset the offset into the buffer
+     * @param count
+     *            the number of bytes to receive
+     * @return the actual number of bytes sent
+     * @throws IOException
      * @throws SocketException
-     *             if the option is invalid
+     *             if an error occurs while writing
      */
-    public native Object getSocketOption(FileDescriptor fd, int opt)
-            throws SocketException;
+    public native int sendStream(FileDescriptor fd, byte[] data, int offset,
+            int count) throws IOException;
+
+    public native void sendUrgentData(FileDescriptor fd, byte value);
+
+    public native void setInetAddress(InetAddress sender, byte[] address);
+
+    public native void setNonBlocking(FileDescriptor fd, boolean block)
+            throws IOException;
 
     /**
      * Set the nominated socket option in the IP stack.
@@ -465,10 +465,12 @@
      * @throws SocketException
      *             if the option is invalid or cannot be set
      */
-    public native void setSocketOption(FileDescriptor aFD, int opt, Object optVal)
-            throws SocketException;
+    public native void setSocketOption(FileDescriptor aFD, int opt,
+            Object optVal) throws SocketException;
 
-    public native int getSocketFlags();
+    public native void shutdownInput(FileDescriptor fd) throws IOException;
+
+    public native void shutdownOutput(FileDescriptor fd) throws IOException;
 
     /**
      * Close the socket in the IP stack.
@@ -478,45 +480,31 @@
      */
     public native void socketClose(FileDescriptor fd) throws IOException;
 
-    public native InetAddress getHostByAddr(byte[] addr) throws UnknownHostException;
-
-    public native InetAddress getHostByName(String addr, boolean preferIPv6Addresses)
-            throws UnknownHostException;
-
-    public native void setInetAddress(InetAddress sender, byte[] address);
+    public native boolean supportsUrgentData(FileDescriptor fd);
 
-    /**
-     * Connect the socket to a port and address
-     * 
-     * @param aFD
-     *            the FileDescriptor to associate with the socket @param port
-     *            the port to connect to
-     * @param trafficClass
-     *            the traffic Class to be used then the connection is made
-     * @param inetAddress
-     *            address to connect to.
-     * 
-     * @exception SocketException
-     *                if the connect fails
+    /*
+     * Used to check if the file descriptor arrays are valid before passing them
+     * into the select native call.
      */
-    static native void connectDatagramImpl2(FileDescriptor aFD, int port,
-            int trafficClass, InetAddress inetAddress) throws SocketException;
-
-    private static native int selectImpl(FileDescriptor[] readfd,
-            FileDescriptor[] writefd, int cread, int cwirte, int[] flags,
-            long timeout);
-
-    private native int isReachableByICMPImpl(InetAddress addr, InetAddress local,
-            int ttl, int timeout);
-
-    public native Channel inheritedChannel();
-
-    public void oneTimeInitialization(boolean jcl_supports_ipv6) {
-        if (!isNetworkInited) {
-            oneTimeInitializationImpl(jcl_supports_ipv6);
-            isNetworkInited = true;
+    private boolean validateFDs(FileDescriptor[] readFDs,
+            FileDescriptor[] writeFDs) {
+        for (FileDescriptor fd : readFDs) {
+            // Also checks fd not null
+            if (!fd.valid()) {
+                return false;
+            }
+        }
+        for (FileDescriptor fd : writeFDs) {
+            if (!fd.valid()) {
+                return false;
+            }
         }
+        return true;
     }
 
-    private native void oneTimeInitializationImpl(boolean jcl_supports_ipv6);
+    public native int write(FileDescriptor fd, byte[] data, int offset,
+            int count) throws IOException;
+
+    public native int writeDirect(FileDescriptor fd, long address, int count)
+            throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h?rev=719920&r1=719919&r2=719920&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h Sat Nov 22 13:16:22 2008
@@ -379,7 +379,7 @@
  * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
  */
 JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl
-  (JNIEnv *, jclass, jobjectArray, jobjectArray, jint, jint, jintArray, jlong);
+  (JNIEnv *, jobject, jobjectArray, jobjectArray, jint, jint, jintArray, jlong);
 
   /*
  * Class:     org_apache_harmony_luni_platform_OSNetworkSystem

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=719920&r1=719919&r2=719920&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c Sat Nov 22 13:16:22 2008
@@ -58,7 +58,9 @@
 
 // Alternative Select function
 int
-selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept){
+selectRead
+(JNIEnv * env, hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept)
+{
   I_32 result = 0;
   I_32 timeout;
   struct pollfd my_pollfd;
@@ -72,8 +74,10 @@
   return result;
 }
 
-JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
-  (JNIEnv * env, jobject clz, jobject address, jobject localaddr,  jint ttl, jint timeout){
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
+  (JNIEnv * env, jobject thiz, jobject address, jobject localaddr, jint ttl, jint timeout)
+{
   PORT_ACCESS_FROM_ENV (env);
   struct sockaddr_in dest,source,local;
 #if !defined(ZOS)
@@ -244,9 +248,11 @@
  * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
  * Assumption: outFlags is zeroed
  */
-JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
-  (JNIEnv * env, jclass	thisClz, jobjectArray readFDArray, jobjectArray	writeFDArray,
-   jint	countReadC, jint countWriteC, jintArray	outFlags, jlong	timeout){
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
+  (JNIEnv * env, jobject thiz, jobjectArray readFDArray, jobjectArray writeFDArray,
+   jint	countReadC, jint countWriteC, jintArray	outFlags, jlong	timeout)
+{
   PORT_ACCESS_FROM_ENV (env);
   I_32 result =	0;		
   hysocket_t hysocketP;		
@@ -313,7 +319,9 @@
   return result;
 };
 
-JNIEXPORT jobject JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannel
+
+JNIEXPORT jobject JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannel
   (JNIEnv * env , jobject thiz)
 {
     PORT_ACCESS_FROM_ENV (env);

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt?rev=719920&r1=719919&r2=719920&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt Sat Nov 22 13:16:22 2008
@@ -221,7 +221,7 @@
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownOutput
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_acceptStreamSocket
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_createStreamSocket
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagramImpl2
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagram2
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketLocalAddress
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_getSocketLocalPort

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c?rev=719920&r1=719919&r2=719920&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c Sat Nov 22 13:16:22 2008
@@ -35,9 +35,11 @@
  * Method:    selectImpl
  * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
  */
-JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
-  (JNIEnv * env, jclass	thisClz, jobjectArray readFDArray, jobjectArray	writeFDArray,
-   jint	countReadC, jint countWriteC, jintArray	outFlags, jlong	timeout){
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
+  (JNIEnv * env, jobject thiz, jobjectArray readFDArray, jobjectArray writeFDArray,
+   jint	countReadC, jint countWriteC, jintArray	outFlags, jlong	timeout)
+{
   PORT_ACCESS_FROM_ENV (env);
   hytimeval_struct timeP;	
   I_32 result =	0;		
@@ -158,7 +160,7 @@
   return result;
 }
 
-/*Alternative Select function*/
+/* Alternative Select function */
 int 
 selectRead (JNIEnv * env,hysocket_t hysocketP, I_32 uSecTime, BOOLEAN accept){
   PORT_ACCESS_FROM_ENV (env);
@@ -192,8 +194,10 @@
  * Method:    isReachableByICMPImpl
  * Signature: ([BII)I
  */
-JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
-  (JNIEnv * env, jobject clz, jobject address,jobject localaddr, jint ttl, jint timeout){
+JNIEXPORT jint JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
+  (JNIEnv * env, jobject clz, jobject address,jobject localaddr, jint ttl, jint timeout)
+{
   PORT_ACCESS_FROM_ENV (env);
   struct sockaddr_in dest,source,local;
   struct ICMPHeader* send_buf = 0;
@@ -328,7 +332,8 @@
     icmp_hdr->checksum = ip_checksum((unsigned short *)icmp_hdr, packet_size);
 }
 
-JNIEXPORT jobject JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannel
+JNIEXPORT jobject JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_inheritedChannel
   (JNIEnv * env , jobject thiz)
 {
   // inheritedChannel is not supported on windows platform.