diff options
| author | Michael Koch <konqueror@gmx.de> | 2003-06-10 19:39:08 +0000 |
|---|---|---|
| committer | Michael Koch <konqueror@gmx.de> | 2003-06-10 19:39:08 +0000 |
| commit | d996ceebdee3762e4a6ae2c5f7b29039aadefa14 (patch) | |
| tree | 0fe026f4d3e21e7634653d4434fe1ccb34499891 /gnu/java/nio/SocketChannelImpl.java | |
| parent | 12083571f8f5b9cf9b071b06b03ca34f5f1331a4 (diff) | |
| download | classpath-d996ceebdee3762e4a6ae2c5f7b29039aadefa14.tar.gz | |
2003-06-10 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/ServerSocketChannelImpl.java,
gnu/java/nio/SocketChannelImpl.java:
Mainly merged with libgcj.
Diffstat (limited to 'gnu/java/nio/SocketChannelImpl.java')
| -rw-r--r-- | gnu/java/nio/SocketChannelImpl.java | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/gnu/java/nio/SocketChannelImpl.java b/gnu/java/nio/SocketChannelImpl.java index d38b11887..48cf585cb 100644 --- a/gnu/java/nio/SocketChannelImpl.java +++ b/gnu/java/nio/SocketChannelImpl.java @@ -80,37 +80,36 @@ public class SocketChannelImpl extends SocketChannel public void finalizer() { if (connected) - { + { try { - close(); + close (); } catch (Exception e) { } - } + } } - protected void implCloseSelectableChannel() + protected void implCloseSelectableChannel () throws IOException { connected = false; SocketClose(fd); fd = SocketCreate(); } - protected void implConfigureBlocking(boolean block) + protected void implConfigureBlocking (boolean blocking) throws IOException { - if (blocking == block) - return; + if (this.blocking == blocking) + return; } - public boolean connect(SocketAddress remote) - throws IOException + public boolean connect (SocketAddress remote) throws IOException { if (connected) - { - throw new AlreadyConnectedException(); - } + { + throw new AlreadyConnectedException (); + } // ok, lets connect ! @@ -130,17 +129,17 @@ public class SocketChannelImpl extends SocketChannel return blocking; } - public boolean finishConnect() + public boolean finishConnect () { return false; } - public boolean isConnected() + public boolean isConnected () { return connected; } - public boolean isConnectionPending() + public boolean isConnectionPending () { if (blocking) return true; @@ -148,7 +147,7 @@ public class SocketChannelImpl extends SocketChannel return false; } - public Socket socket() + public Socket socket () { if (sock_object != null) { @@ -158,7 +157,7 @@ public class SocketChannelImpl extends SocketChannel return sock_object; } - public int read(ByteBuffer dst) + public int read (ByteBuffer dst) throws IOException { int bytes = 0; int len = 1024; @@ -168,27 +167,29 @@ public class SocketChannelImpl extends SocketChannel dst.put(b, 0, bytes); if (bytes == 0) - { + { // we've hit eof ? return -1; - } + } return bytes; } - public long read(ByteBuffer[] dsts, int offset, int length) + public long read (ByteBuffer[] dsts, int offset, int length) + throws IOException { long bytes = 0; - for (int i=offset; i<length; i++) - { - bytes += read(dsts[i]); - } + for (int i = offset; i < length; i++) + { + bytes += read (dsts [i]); + } return bytes; } - public int write(ByteBuffer src) + public int write (ByteBuffer src) + throws IOException { int bytes = 0; int len = src.position(); @@ -205,17 +206,18 @@ public class SocketChannelImpl extends SocketChannel bytes = SocketWrite (fd, b, 0, len); } - return bytes; + return bytes; } public long write (ByteBuffer[] srcs, int offset, int length) + throws IOException { long bytes = 0; - for (int i=offset; i<length; i++) - { - bytes += write(srcs[i]); - } + for (int i = offset; i < length; i++) + { + bytes += write (srcs [i]); + } return bytes; } |
