]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2004-11-21 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Sun, 21 Nov 2004 20:19:59 +0000 (20:19 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Sun, 21 Nov 2004 20:19:59 +0000 (20:19 +0000)
* gnu/java/nio/SocketChannelImpl.java
(read): Only return 0 when no bytes for reading available in
non-blocking mode.
* java/nio/channels/SocketChannel.java:
Added some missing @return tags.

From-SVN: r90986

libjava/ChangeLog
libjava/gnu/java/nio/SocketChannelImpl.java
libjava/java/nio/channels/SocketChannel.java

index 28bf7222d15dc522681b14077ac3410650475dcc..e3ae8ec75c5a7f7729b90954f17394088ae39e28 100644 (file)
@@ -1,3 +1,11 @@
+2004-11-21  Michael Koch  <konqueror@gmx.de>
+
+       * gnu/java/nio/SocketChannelImpl.java
+       (read): Only return 0 when no bytes for reading available in
+       non-blocking mode.
+       * java/nio/channels/SocketChannel.java:
+       Added some missing @return tags.
+
 2004-11-21  Michael Koch  <konqueror@gmx.de>
 
        * java/beans/PropertyChangeSupport.java
index c67b7cb7bb72896af50a7be9e91ad0fa9fb9f991..23db8922687b4a80694264eff483116eafc71fa9 100644 (file)
@@ -182,7 +182,7 @@ public final class SocketChannelImpl extends SocketChannel
     // FIXME: Handle blocking/non-blocking mode.
 
     Selector selector = provider().openSelector();
-    register (selector, SelectionKey.OP_CONNECT);
+    register(selector, SelectionKey.OP_CONNECT);
 
     if (isBlocking())
       {
@@ -216,7 +216,7 @@ public final class SocketChannelImpl extends SocketChannel
     return socket;
   }
 
-  public int read (ByteBuffer dst) throws IOException
+  public int read(ByteBuffer dst) throws IOException
   {
     if (!isConnected())
       throw new NotYetConnectedException();
@@ -227,7 +227,7 @@ public final class SocketChannelImpl extends SocketChannel
     int available = input.available();
     int len = dst.capacity() - dst.position();
        
-    if (available == 0)
+    if (! isBlocking() && available == 0)
       return 0;
     
     if (len > available)
index 933f866c9a5b789755407667d0f0a9cdc8bcc4f2..650df036605e91ae0a0452aa79fb074c98c63253 100644 (file)
@@ -1,5 +1,5 @@
 /* SocketChannel.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.nio.channels;
 
 import java.io.IOException;
@@ -44,16 +45,15 @@ import java.nio.ByteBuffer;
 import java.nio.channels.spi.AbstractSelectableChannel;
 import java.nio.channels.spi.SelectorProvider;
 
-
 /**
- * @author Michael Koch
+ * @author Michael Koch (konqueror@gmx.de)
  * @since 1.4
  */
 public abstract class SocketChannel extends AbstractSelectableChannel
   implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
 {
   /**
-   * Initializes this socket.
+   * Initializes this socket channel.
    */
   protected SocketChannel(SelectorProvider provider)
   {
@@ -63,6 +63,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Opens a socket channel.
    *
+   * @return the new <code>SocketChannel</code> object
+   * 
    * @exception IOException If an error occurs
    */
   public static SocketChannel open() throws IOException
@@ -73,6 +75,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Opens a channel and connects it to a remote address.
    *
+   * @return the new <code>SocketChannel</code> object
+   * 
    * @exception AsynchronousCloseException If this channel is already connected.
    * @exception ClosedByInterruptException If another thread interrupts the
    * current thread while the connect operation is in progress, thereby closing
@@ -96,6 +100,9 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Reads data from the channel.
    *
+   * @return the number of bytes read, zero is valid too, -1 if end of stream
+   * is reached
+   *
    * @exception IOException If an error occurs
    * @exception NotYetConnectedException If this channel is not yet connected.
    */
@@ -112,6 +119,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Writes data to the channel.
    *
+   * @return the number of bytes written, zero is valid too
+   * 
    * @exception IOException If an error occurs
    * @exception NotYetConnectedException If this channel is not yet connected.
    */
@@ -127,6 +136,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel
 
   /**
    * Retrieves the valid operations for this channel.
+   *
+   * @return the valid operations
    */
   public final int validOps()
   {
@@ -137,6 +148,9 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Reads data from the channel.
    *
+   * @return the number of bytes read, zero is valid too, -1 if end of stream
+   * is reached
+   * 
    * @exception IOException If an error occurs
    * @exception NotYetConnectedException If this channel is not yet connected.
    */
@@ -145,6 +159,10 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Connects the channel's socket to the remote address.
    *
+   * @return <code>true</code> if the channel got successfully connected,
+   * <code>false</code> if the channel is in non-blocking mode and connection
+   * operation is still in progress.
+   * 
    * @exception AlreadyConnectedException If this channel is already connected.
    * @exception AsynchronousCloseException If this channel is already connected.
    * @exception ClosedByInterruptException If another thread interrupts the
@@ -191,6 +209,9 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Reads data from the channel.
    *
+   * @return the number of bytes read, zero is valid too, -1 if end of stream
+   * is reached
+   * 
    * @exception IOException If an error occurs
    * @exception NotYetConnectedException If this channel is not yet connected.
    */
@@ -199,12 +220,16 @@ public abstract class SocketChannel extends AbstractSelectableChannel
 
   /**
    * Retrieves the channel's socket.
+   *
+   * @return the socket
    */
   public abstract Socket socket();
 
   /**
    * Writes data to the channel.
    *
+   * @return the number of bytes written, zero is valid too
+   * 
    * @exception IOException If an error occurs
    * @exception NotYetConnectedException If this channel is not yet connected.
    */
@@ -213,6 +238,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel
   /**
    * Writes data to the channel.
    *
+   * @return the number of bytes written, zero is valid too
+   * 
    * @exception IOException If an error occurs
    * @exception NotYetConnectedException If this channel is not yet connected.
    */