aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/nio/SocketChannelImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/java/nio/SocketChannelImpl.java')
-rw-r--r--libjava/gnu/java/nio/SocketChannelImpl.java61
1 files changed, 13 insertions, 48 deletions
diff --git a/libjava/gnu/java/nio/SocketChannelImpl.java b/libjava/gnu/java/nio/SocketChannelImpl.java
index 820d62f..94913fb 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;
}