2003-06-19 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/DatagramChannelImpl.java (fd): Removed. (blocking): New member variable. (socket): Likewise. (DatagramChannelImpl): Throws IOException, initialize socket. (socket):Implemented. (implCloseSelectableChannel): Throws IOException, implemented. (implConfigureBlocking): Likewise. (connect): Likewise. (disconnect): Likewise. (isConnected): Likewise. (write): Likewise. (read): Likewise. (receive): Throws IOException. (send): Likewise. * gnu/java/nio/SocketChannelImpl.java (read): Implemented. (write): Implemented. From-SVN: r68208
This commit is contained in:
parent
536a695f04
commit
98a91a724e
3 changed files with 140 additions and 80 deletions
|
@ -118,22 +118,21 @@ public class SocketChannelImpl extends SocketChannel
|
|||
|
||||
public int read (ByteBuffer dst) throws IOException
|
||||
{
|
||||
byte[] data;
|
||||
int bytes = 0;
|
||||
int len = 1024;
|
||||
byte[]b = new byte[len];
|
||||
int len = dst.remaining ();
|
||||
|
||||
/*
|
||||
bytes = SocketRead(fd, b, 0, len);
|
||||
dst.put(b, 0, bytes);
|
||||
|
||||
if (bytes == 0)
|
||||
if (!dst.hasArray ())
|
||||
{
|
||||
// we've hit eof ?
|
||||
return -1;
|
||||
data = new byte [len];
|
||||
dst.get (data, 0, len);
|
||||
}
|
||||
*/
|
||||
|
||||
return bytes;
|
||||
else
|
||||
{
|
||||
data = dst.array ();
|
||||
}
|
||||
|
||||
return socket.getInputStream().read (data, 0, len);
|
||||
}
|
||||
|
||||
public long read (ByteBuffer[] dsts, int offset, int length)
|
||||
|
@ -152,24 +151,22 @@ public class SocketChannelImpl extends SocketChannel
|
|||
public int write (ByteBuffer src)
|
||||
throws IOException
|
||||
{
|
||||
byte[] data;
|
||||
int bytes = 0;
|
||||
int len = src.position();
|
||||
|
||||
/*
|
||||
if (src.hasArray ())
|
||||
int len = src.remaining ();
|
||||
|
||||
if (!src.hasArray ())
|
||||
{
|
||||
byte[] b = src.array ();
|
||||
bytes = SocketWrite (fd, b, 0, len);
|
||||
data = new byte [len];
|
||||
src.get (data, 0, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] b = new byte [len];
|
||||
src.get (b, 0, len);
|
||||
bytes = SocketWrite (fd, b, 0, len);
|
||||
data = src.array ();
|
||||
}
|
||||
*/
|
||||
|
||||
return bytes;
|
||||
|
||||
socket.getOutputStream().write (data, 0, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
public long write (ByteBuffer[] srcs, int offset, int length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue