Commit 299f5809 by Michael Koch Committed by Michael Koch

2003-06-18 Michael Koch <konqueror@gmx.de>

	* 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
parent 20d513ff
2003-06-18 Michael Koch <konqueror@gmx.de> 2003-06-18 Michael Koch <konqueror@gmx.de>
* 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.
2003-06-18 Michael Koch <konqueror@gmx.de>
* java/util/Locale.java * java/util/Locale.java
(equals): Merged from classpath. (equals): Merged from classpath.
......
...@@ -2568,7 +2568,6 @@ gnu/java/nio/natFileChannelImpl.cc \ ...@@ -2568,7 +2568,6 @@ gnu/java/nio/natFileChannelImpl.cc \
gnu/java/nio/natFileLockImpl.cc \ gnu/java/nio/natFileLockImpl.cc \
gnu/java/nio/natMappedByteFileBuffer.cc \ gnu/java/nio/natMappedByteFileBuffer.cc \
gnu/java/nio/natSelectorImpl.cc \ gnu/java/nio/natSelectorImpl.cc \
gnu/java/nio/natSocketChannelImpl.cc \
java/io/natFile.cc \ java/io/natFile.cc \
java/io/natFileDescriptor.cc \ java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \ java/io/natObjectInputStream.cc \
......
...@@ -2329,7 +2329,6 @@ gnu/java/nio/natFileChannelImpl.cc \ ...@@ -2329,7 +2329,6 @@ gnu/java/nio/natFileChannelImpl.cc \
gnu/java/nio/natFileLockImpl.cc \ gnu/java/nio/natFileLockImpl.cc \
gnu/java/nio/natMappedByteFileBuffer.cc \ gnu/java/nio/natMappedByteFileBuffer.cc \
gnu/java/nio/natSelectorImpl.cc \ gnu/java/nio/natSelectorImpl.cc \
gnu/java/nio/natSocketChannelImpl.cc \
java/io/natFile.cc \ java/io/natFile.cc \
java/io/natFileDescriptor.cc \ java/io/natFileDescriptor.cc \
java/io/natObjectInputStream.cc \ java/io/natObjectInputStream.cc \
...@@ -2503,13 +2502,13 @@ gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \ ...@@ -2503,13 +2502,13 @@ gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \
gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \ gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \
gnu/gcj/runtime/natVMClassLoader.lo gnu/java/nio/natFileChannelImpl.lo \ gnu/gcj/runtime/natVMClassLoader.lo gnu/java/nio/natFileChannelImpl.lo \
gnu/java/nio/natFileLockImpl.lo gnu/java/nio/natMappedByteFileBuffer.lo \ gnu/java/nio/natFileLockImpl.lo gnu/java/nio/natMappedByteFileBuffer.lo \
gnu/java/nio/natSelectorImpl.lo gnu/java/nio/natSocketChannelImpl.lo \ gnu/java/nio/natSelectorImpl.lo java/io/natFile.lo \
java/io/natFile.lo java/io/natFileDescriptor.lo \ java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \
java/io/natObjectInputStream.lo java/io/natVMObjectStreamClass.lo \ java/io/natVMObjectStreamClass.lo java/lang/natCharacter.lo \
java/lang/natCharacter.lo java/lang/natClass.lo \ java/lang/natClass.lo java/lang/natClassLoader.lo \
java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \ java/lang/natConcreteProcess.lo java/lang/natDouble.lo \
java/lang/natDouble.lo java/lang/natFloat.lo java/lang/natMath.lo \ java/lang/natFloat.lo java/lang/natMath.lo java/lang/natObject.lo \
java/lang/natObject.lo java/lang/natRuntime.lo java/lang/natString.lo \ java/lang/natRuntime.lo java/lang/natString.lo \
java/lang/natStringBuffer.lo java/lang/natSystem.lo \ java/lang/natStringBuffer.lo java/lang/natSystem.lo \
java/lang/natThread.lo java/lang/natVMSecurityManager.lo \ java/lang/natThread.lo java/lang/natVMSecurityManager.lo \
java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \ java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \
...@@ -2984,7 +2983,6 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ ...@@ -2984,7 +2983,6 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/nio/natFileLockImpl.P \ .deps/gnu/java/nio/natFileLockImpl.P \
.deps/gnu/java/nio/natMappedByteFileBuffer.P \ .deps/gnu/java/nio/natMappedByteFileBuffer.P \
.deps/gnu/java/nio/natSelectorImpl.P \ .deps/gnu/java/nio/natSelectorImpl.P \
.deps/gnu/java/nio/natSocketChannelImpl.P \
.deps/gnu/java/rmi/RMIMarshalledObjectInputStream.P \ .deps/gnu/java/rmi/RMIMarshalledObjectInputStream.P \
.deps/gnu/java/rmi/RMIMarshalledObjectOutputStream.P \ .deps/gnu/java/rmi/RMIMarshalledObjectOutputStream.P \
.deps/gnu/java/rmi/dgc/DGCImpl.P .deps/gnu/java/rmi/dgc/DGCImpl_Skel.P \ .deps/gnu/java/rmi/dgc/DGCImpl.P .deps/gnu/java/rmi/dgc/DGCImpl_Skel.P \
......
...@@ -255,17 +255,17 @@ public class SelectorImpl extends AbstractSelector ...@@ -255,17 +255,17 @@ public class SelectorImpl extends AbstractSelector
if (ch instanceof SocketChannelImpl) if (ch instanceof SocketChannelImpl)
{ {
SocketChannelImpl sc = (SocketChannelImpl) ch; SocketChannelImpl sc = (SocketChannelImpl) ch;
result = new SelectionKeyImpl (ch, this, sc.fd); result = new SelectionKeyImpl (ch, this, 0); // FIXME: last argument
} }
else if (ch instanceof DatagramChannelImpl) else if (ch instanceof DatagramChannelImpl)
{ {
DatagramChannelImpl dc = (DatagramChannelImpl) ch; DatagramChannelImpl dc = (DatagramChannelImpl) ch;
result = new SelectionKeyImpl (ch, this, dc.fd); result = new SelectionKeyImpl (ch, this, 0); // FIXME: last argument
} }
else if (ch instanceof ServerSocketChannelImpl) else if (ch instanceof ServerSocketChannelImpl)
{ {
ServerSocketChannelImpl ssc = (ServerSocketChannelImpl) ch; ServerSocketChannelImpl ssc = (ServerSocketChannelImpl) ch;
result = new SelectionKeyImpl (ch, this, ssc.fd); result = new SelectionKeyImpl (ch, this, 0); // FIXME: last argument
} }
else else
{ {
......
...@@ -35,11 +35,13 @@ this exception to your version of the library, but you are not ...@@ -35,11 +35,13 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package gnu.java.nio; package gnu.java.nio;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.ServerSocketChannel; import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
...@@ -48,26 +50,14 @@ import java.nio.channels.spi.SelectorProvider; ...@@ -48,26 +50,14 @@ import java.nio.channels.spi.SelectorProvider;
class ServerSocketChannelImpl extends ServerSocketChannel class ServerSocketChannelImpl extends ServerSocketChannel
{ {
ServerSocket serverSocket; ServerSocket serverSocket;
int fd;
// int local_port;
boolean blocking = true; boolean blocking = true;
boolean connected = false; boolean connected = false;
// InetSocketAddress sa;
protected ServerSocketChannelImpl (SelectorProvider provider) protected ServerSocketChannelImpl (SelectorProvider provider)
throws IOException throws IOException
{ {
super (provider); super (provider);
fd = SocketChannelImpl.SocketCreate (); serverSocket = new ServerSocket ();
try
{
serverSocket = new ServerSocket ();
}
catch (IOException e)
{
System.err.println ("ServerSocket could not be created.");
}
} }
public void finalizer() public void finalizer()
...@@ -87,20 +77,19 @@ class ServerSocketChannelImpl extends ServerSocketChannel ...@@ -87,20 +77,19 @@ class ServerSocketChannelImpl extends ServerSocketChannel
protected void implCloseSelectableChannel () throws IOException protected void implCloseSelectableChannel () throws IOException
{ {
connected = false; connected = false;
SocketChannelImpl.SocketClose (fd); serverSocket.close();
fd = SocketChannelImpl.SocketCreate ();
} }
protected void implConfigureBlocking (boolean blocking) throws IOException protected void implConfigureBlocking (boolean blocking) throws IOException
{ {
this.blocking = blocking; this.blocking = blocking; // FIXME
} }
public SocketChannel accept () throws IOException public SocketChannel accept () throws IOException
{ {
SocketChannelImpl result = new SocketChannelImpl (provider ()); SocketChannelImpl result = new SocketChannelImpl (provider ());
result.sa = new InetSocketAddress (0); Socket socket = serverSocket.accept();
//int res = SocketAccept (this,result); //socket.setChannel (result); // FIXME
return result; return result;
} }
......
...@@ -52,30 +52,13 @@ import gnu.classpath.Configuration; ...@@ -52,30 +52,13 @@ import gnu.classpath.Configuration;
public class SocketChannelImpl extends SocketChannel public class SocketChannelImpl extends SocketChannel
{ {
Socket socket; Socket socket;
int fd;
int local_port;
boolean blocking = true; boolean blocking = true;
boolean connected = false; boolean connected = false;
InetSocketAddress sa;
public SocketChannelImpl (SelectorProvider provider)
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)
{ {
super(provider); super (provider);
fd = SocketCreate(); socket = new Socket ();
if (fd == -1)
{
System.err.println("failed to create socket:"+fd);
}
} }
public void finalizer() public void finalizer()
...@@ -95,39 +78,22 @@ public class SocketChannelImpl extends SocketChannel ...@@ -95,39 +78,22 @@ public class SocketChannelImpl extends SocketChannel
protected void implCloseSelectableChannel () throws IOException protected void implCloseSelectableChannel () throws IOException
{ {
connected = false; connected = false;
SocketClose(fd); socket.close();
fd = SocketCreate();
} }
protected void implConfigureBlocking (boolean blocking) throws IOException protected void implConfigureBlocking (boolean blocking) throws IOException
{ {
if (this.blocking == blocking) this.blocking = blocking; // FIXME
return;
} }
public boolean connect (SocketAddress remote) throws IOException public boolean connect (SocketAddress remote) throws IOException
{ {
if (connected) if (connected)
{ throw new AlreadyConnectedException();
throw new AlreadyConnectedException ();
}
// ok, lets connect !
sa = (InetSocketAddress) remote; socket.connect (remote, 50);
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;
connected = true; connected = true;
return blocking; return blocking; // FIXME
} }
public boolean finishConnect () public boolean finishConnect ()
...@@ -147,11 +113,6 @@ public class SocketChannelImpl extends SocketChannel ...@@ -147,11 +113,6 @@ public class SocketChannelImpl extends SocketChannel
public Socket socket () public Socket socket ()
{ {
if (socket != null)
{
//socket.ch = this;
}
return socket; return socket;
} }
...@@ -161,6 +122,7 @@ public class SocketChannelImpl extends SocketChannel ...@@ -161,6 +122,7 @@ public class SocketChannelImpl extends SocketChannel
int len = 1024; int len = 1024;
byte[]b = new byte[len]; byte[]b = new byte[len];
/*
bytes = SocketRead(fd, b, 0, len); bytes = SocketRead(fd, b, 0, len);
dst.put(b, 0, bytes); dst.put(b, 0, bytes);
...@@ -169,6 +131,7 @@ public class SocketChannelImpl extends SocketChannel ...@@ -169,6 +131,7 @@ public class SocketChannelImpl extends SocketChannel
// we've hit eof ? // we've hit eof ?
return -1; return -1;
} }
*/
return bytes; return bytes;
} }
...@@ -192,6 +155,7 @@ public class SocketChannelImpl extends SocketChannel ...@@ -192,6 +155,7 @@ public class SocketChannelImpl extends SocketChannel
int bytes = 0; int bytes = 0;
int len = src.position(); int len = src.position();
/*
if (src.hasArray ()) if (src.hasArray ())
{ {
byte[] b = src.array (); byte[] b = src.array ();
...@@ -203,6 +167,7 @@ public class SocketChannelImpl extends SocketChannel ...@@ -203,6 +167,7 @@ public class SocketChannelImpl extends SocketChannel
src.get (b, 0, len); src.get (b, 0, len);
bytes = SocketWrite (fd, b, 0, len); bytes = SocketWrite (fd, b, 0, len);
} }
*/
return bytes; return bytes;
} }
......
...@@ -73,7 +73,8 @@ gnu::java::nio::FileChannelImpl::implTruncate (jlong size) ...@@ -73,7 +73,8 @@ gnu::java::nio::FileChannelImpl::implTruncate (jlong size)
} }
gnu::gcj::RawData* gnu::gcj::RawData*
gnu::java::nio::FileChannelImpl::nio_mmap_file (jlong pos, jlong size, jint /*mode*/) gnu::java::nio::FileChannelImpl::nio_mmap_file (jlong pos, jlong size,
jint /*mode*/)
{ {
throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented")); throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented"));
} }
......
// natSocketChannelImpl.cc
/* Copyright (C) 2002, 2003 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
#include <platform.h>
#include <errno.h>
#include <gcj/cni.h>
#include <gnu/java/nio/SocketChannelImpl.h>
#include <java/io/IOException.h>
#include <java/net/InetAddress.h>
#include <java/net/SocketException.h>
#ifdef DISABLE_JAVA_NET
jint
gnu::java::nio::SocketChannelImpl::SocketCreate ()
{
throw new ::java::io::IOException (JvNewStringUTF ("SocketCreate not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketConnect (jint,
::java::net::InetAddress *,
jint)
{
throw new ::java::io::IOException (JvNewStringUTF ("SocketConnect not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketBind (jint, ::java::net::InetAddress *,
jint)
{
throw new ::java::io::IOException (JvNewStringUTF ("SocketBind not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketListen (jint, jint)
{
throw new ::java::io::IOException (JvNewStringUTF ("SocketList not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketAvailable (jint)
{
throw new ::java::net::SocketException (JvNewStringLatin1 ("SocketAvailable: not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketClose (jint)
{
throw new ::java::net::SocketException (JvNewStringLatin1 ("SocketClose: not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketRead (jint, jbyteArray, jint, jint)
{
throw new ::java::net::SocketException (JvNewStringLatin1 ("SocketRead: not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketWrite (jint, jbyteArray, jint, jint)
{
throw new ::java::net::SocketException (JvNewStringLatin1 ("SocketWrite: not implemented"));
}
#else // DISABLE_JAVA_NET
jint
gnu::java::nio::SocketChannelImpl::SocketCreate ()
{
int sock = _Jv_socket (AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
char* strerr = strerror (errno);
throw new ::java::io::IOException (JvNewStringUTF (strerr));
}
return sock;
}
jint
gnu::java::nio::SocketChannelImpl::SocketConnect (jint fd,
::java::net::InetAddress *addr,
jint port)
{
throw new ::java::io::IOException (JvNewStringUTF ("SocketConnect not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketBind (jint fd,
::java::net::InetAddress *addr,
jint port)
{
throw new ::java::io::IOException (JvNewStringUTF ("SocketBind not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketListen (jint fd, jint backlog)
{
int result = _Jv_listen (fd, backlog);
if (result < 0)
{
char* strerr = strerror (errno);
throw new ::java::io::IOException (JvNewStringUTF (strerr));
}
return result;
}
jint
gnu::java::nio::SocketChannelImpl::SocketAvailable (jint /*fd*/)
{
throw new ::java::net::SocketException (JvNewStringLatin1 ("SocketAvailable: not implemented"));
}
jint
gnu::java::nio::SocketChannelImpl::SocketClose (jint fd)
{
int result = _Jv_close (fd);
if (result < 0)
{
char* strerr = strerror (errno);
throw new ::java::io::IOException (JvNewStringUTF (strerr));
}
return result;
}
jint
gnu::java::nio::SocketChannelImpl::SocketRead (jint fd, jbyteArray data,
jint offset, jint length)
{
int result = ::recv (fd, data, offset, length);
if (result < 0)
{
char* strerr = strerror (errno);
throw new ::java::io::IOException (JvNewStringUTF (strerr));
}
return result;
}
jint
gnu::java::nio::SocketChannelImpl::SocketWrite (jint fd, jbyteArray data,
jint offset, jint length)
{
int result = ::send (fd, data, offset, length);
if (result < 0)
{
char* strerr = strerror (errno);
throw new ::java::io::IOException (JvNewStringUTF (strerr));
}
return result;
}
#endif // DISABLE_JAVA_NET
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment