From 299f5809e2d4bafeacb8d05d89da423f0e179a28 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Wed, 18 Jun 2003 08:56:55 +0000 Subject: 2003-06-18 Michael Koch * gnu/java/nio/SelectorImpl.java (register): Use fd with value 0 for now, will be fixed later. * gnu/java/nio/ServerSocketChannelImpl.java (fd): Removed. (local_port): Removed. (InetSocketAddress): Removed. (ServerSocketChannelImpl): Just initialize internal socket object. (implCloseSelectableChannel): Close internal socket object. (implConfigureBlocking): Added comment. (accept): Use jaba.net stuff to accept socket. * gnu/java/nio/SocketChannelImpl.java (fd): Removed. (local_port): Removed. (InetSocketAddress): Removed. (SocketCreate): Removed. (SocketConnect): Removed. (SocketBind): Removed. (SocketListen): Removed. (SocketAvailable): Removed. (SocketClose): Removed. (SocketRead): Removed. (SocketWrite): Removed. (SocketChannelImpl): Just initialize internal socket object. (implCloseSelectableChannel): Close internal socket object. (implConfigureBlocking): Fixed implementation, added comment. (connect): Use internal socket object to connect. (socket): No need for sanity checks. (read): Comment out some stuff, this will be reimplemented in the next commit. (write): Likewise. * gnu/java/nio/natFileChannelImpl.cc (nio_mmap_file): Line wrapped. * gnu/java/nio/natSocketChannelImpl.cc: Removed. * Makefile.am (nat_source_files): Removeded gnu/java/nio/natSocketChannelImpl.cc. * Makefile.in: Regenerated. From-SVN: r68145 --- libjava/gnu/java/nio/SocketChannelImpl.java | 61 ++++++----------------------- 1 file changed, 13 insertions(+), 48 deletions(-) (limited to 'libjava/gnu/java/nio/SocketChannelImpl.java') diff --git a/libjava/gnu/java/nio/SocketChannelImpl.java b/libjava/gnu/java/nio/SocketChannelImpl.java index 820d62f3b6c..94913fb8ac7 100644 --- a/libjava/gnu/java/nio/SocketChannelImpl.java +++ b/libjava/gnu/java/nio/SocketChannelImpl.java @@ -52,30 +52,13 @@ import gnu.classpath.Configuration; public class SocketChannelImpl extends SocketChannel { Socket socket; - int fd; - int local_port; boolean blocking = true; boolean connected = false; - InetSocketAddress sa; - - static native int SocketCreate(); - static native int SocketConnect(int fd, InetAddress addr, int port); - static native int SocketBind(int fd, InetAddress addr, int port); - static native int SocketListen(int fd, int backlog); - static native int SocketAvailable(int fd); - static native int SocketClose(int fd); - static native int SocketRead(int fd, byte b[], int off, int len); - static native int SocketWrite(int fd, byte b[], int off, int len); - - public SocketChannelImpl(SelectorProvider provider) + + public SocketChannelImpl (SelectorProvider provider) { - super(provider); - fd = SocketCreate(); - - if (fd == -1) - { - System.err.println("failed to create socket:"+fd); - } + super (provider); + socket = new Socket (); } public void finalizer() @@ -95,39 +78,22 @@ public class SocketChannelImpl extends SocketChannel protected void implCloseSelectableChannel () throws IOException { connected = false; - SocketClose(fd); - fd = SocketCreate(); + socket.close(); } protected void implConfigureBlocking (boolean blocking) throws IOException { - if (this.blocking == blocking) - return; + this.blocking = blocking; // FIXME } public boolean connect (SocketAddress remote) throws IOException { if (connected) - { - throw new AlreadyConnectedException (); - } - - // ok, lets connect ! + throw new AlreadyConnectedException(); - sa = (InetSocketAddress) remote; - - InetAddress addr = sa.getAddress(); - int port = sa.getPort(); - int err = SocketConnect(fd, addr, port); - - if (err < 0) - { - throw new IOException("Connection refused:"+err + ", connect="+err); - } - - local_port = err; + socket.connect (remote, 50); connected = true; - return blocking; + return blocking; // FIXME } public boolean finishConnect () @@ -147,11 +113,6 @@ public class SocketChannelImpl extends SocketChannel public Socket socket () { - if (socket != null) - { - //socket.ch = this; - } - return socket; } @@ -161,6 +122,7 @@ public class SocketChannelImpl extends SocketChannel int len = 1024; byte[]b = new byte[len]; + /* bytes = SocketRead(fd, b, 0, len); dst.put(b, 0, bytes); @@ -169,6 +131,7 @@ public class SocketChannelImpl extends SocketChannel // we've hit eof ? return -1; } + */ return bytes; } @@ -192,6 +155,7 @@ public class SocketChannelImpl extends SocketChannel int bytes = 0; int len = src.position(); + /* if (src.hasArray ()) { byte[] b = src.array (); @@ -203,6 +167,7 @@ public class SocketChannelImpl extends SocketChannel src.get (b, 0, len); bytes = SocketWrite (fd, b, 0, len); } + */ return bytes; } -- cgit v1.2.3