/[classpath]/classpath/gnu/java/nio/SocketChannelImpl.java
ViewVC logotype

Diff of /classpath/gnu/java/nio/SocketChannelImpl.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by mkoch, Wed Jun 18 09:45:00 2003 UTC revision 1.14 by mkoch, Fri Jun 20 05:35:34 2003 UTC
# Line 118  public class SocketChannelImpl extends S Line 118  public class SocketChannelImpl extends S
118    
119    public int read (ByteBuffer dst) throws IOException    public int read (ByteBuffer dst) throws IOException
120    {    {
121        byte[] data;
122      int bytes = 0;      int bytes = 0;
123      int len = 1024;      int len = dst.remaining ();
     byte[]b = new byte[len];  
124                    
125      /*      if (!dst.hasArray ())
     bytes = SocketRead(fd, b, 0, len);  
     dst.put(b, 0, bytes);  
   
     if (bytes == 0)  
126        {        {
127          // we've hit eof ?          data = new byte [len];
128          return -1;          dst.get (data, 0, len);
129        }        }
130      */      else
131          {
132      return bytes;          data = dst.array ();
133          }
134        
135        return socket.getInputStream().read (data, 0, len);
136    }    }
137            
138    public long read (ByteBuffer[] dsts, int offset, int length)    public long read (ByteBuffer[] dsts, int offset, int length)
# Line 152  public class SocketChannelImpl extends S Line 151  public class SocketChannelImpl extends S
151    public int write (ByteBuffer src)    public int write (ByteBuffer src)
152      throws IOException      throws IOException
153    {    {
154        byte[] data;
155      int bytes = 0;      int bytes = 0;
156      int len = src.position();      int len = src.remaining ();
157        
158      /*      if (!src.hasArray ())
     if (src.hasArray ())  
159        {        {
160          byte[] b = src.array ();          data = new byte [len];
161          bytes = SocketWrite (fd, b, 0, len);          src.get (data, 0, len);
162        }        }
163      else      else
164        {        {
165          byte[] b = new byte [len];          data = src.array ();
         src.get (b, 0, len);  
         bytes = SocketWrite (fd, b, 0, len);  
166        }        }
167      */    
168                        socket.getOutputStream().write (data, 0, len);
169      return bytes;      return len;
170    }    }
171    
172    public long write (ByteBuffer[] srcs, int offset, int length)    public long write (ByteBuffer[] srcs, int offset, int length)

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26