This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: java.net socket fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 18 Sep 2003 13:34:18 +0200
- Subject: FYI: Patch: java.net socket fixes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I wrote a little patch to fix java.net sockets. They dont have to
handle java.nio channels. They just have to provide the framework.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/aZg7WSOgCCdjSDsRAjHVAJ98Pn+PAH3o+i2r1RBr1Lkevi0x9wCfYGJt
TRsp5zzi2QWDCxu7xJuoKog=
=F7if
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2152
diff -u -b -B -r1.2152 ChangeLog
--- ChangeLog 18 Sep 2003 11:24:20 -0000 1.2152
+++ ChangeLog 18 Sep 2003 11:30:40 -0000
@@ -1,3 +1,22 @@
+2003-09-18 Michael Koch <konqueror@gmx.de>
+
+ * java/net/DatagramSocket.java
+ (ch): Removed.
+ (receive): Use getChannel() instead of ch.
+ (send): Likewise.
+ (getChannel): Return null.
+ * java/net/ServerSocket.java
+ (ch): Removed.
+ (setChannel): Removed.
+ (implAccept): Use getChannel() instead of ch.
+ (close): Likewise.
+ (getChannel): Return null.
+ * java/net/Socket.java
+ (ch): Removed.
+ (connect): Use getChannel() instead of ch.
+ (setChannel): Removed.
+ (getChannel): Return null.
+
2003-09-18 Mark Wielaard <mark@klomp.org>
Reported by Guilhem Lavaux and Julian Dolby
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.27
diff -u -b -B -r1.27 DatagramSocket.java
--- java/net/DatagramSocket.java 10 Sep 2003 17:39:18 -0000 1.27
+++ java/net/DatagramSocket.java 18 Sep 2003 11:30:40 -0000
@@ -75,12 +75,6 @@
DatagramSocketImpl impl;
/**
- * The unique DatagramChannel object associated with this datagram socket,
- * or null.
- */
- DatagramChannel ch;
-
- /**
* This is the address we are "connected" to
*/
private InetAddress remoteAddress;
@@ -519,7 +513,8 @@
throw new IOException (
"Socket connected to a multicast address my not receive");
- if (ch != null && !ch.isBlocking ())
+ if (getChannel() != null
+ && !getChannel().isBlocking ())
throw new IllegalBlockingModeException ();
impl.receive(p);
@@ -568,7 +563,8 @@
// FIXME: if this is a subclass of MulticastSocket,
// use getTimeToLive for TTL val.
- if (ch != null && !ch.isBlocking ())
+ if (getChannel() != null
+ && !getChannel().isBlocking ())
throw new IllegalBlockingModeException ();
impl.send(p);
@@ -618,7 +614,7 @@
*/
public DatagramChannel getChannel()
{
- return ch;
+ return null;
}
/**
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.25
diff -u -b -B -r1.25 ServerSocket.java
--- java/net/ServerSocket.java 10 Sep 2003 17:39:18 -0000 1.25
+++ java/net/ServerSocket.java 18 Sep 2003 11:30:40 -0000
@@ -73,12 +73,6 @@
*/
private SocketImpl impl;
- /**
- * ServerSocketChannel of this ServerSocket. This channel only exists
- * when the socket is created by ServerSocketChannel.open().
- */
- private ServerSocketChannel ch;
-
private boolean closed = false;
/**
@@ -160,14 +154,6 @@
bind (new InetSocketAddress (bindAddr, port), backlog);
}
- /*
- * This method may only be used by java.nio.channels.ServerSocketChannel.open.
- */
- void setChannel (ServerSocketChannel ch)
- {
- this.ch = ch;
- }
-
/**
* Binds the server socket to a specified socket address
*
@@ -318,7 +304,8 @@
protected final void implAccept (Socket s)
throws IOException
{
- if (ch != null && !ch.isBlocking())
+ if (getChannel() != null
+ && !getChannel().isBlocking())
throw new IllegalBlockingModeException();
impl.accept(s.impl);
@@ -334,8 +321,8 @@
if (impl != null)
impl.close ();
- if (ch != null)
- ch.close ();
+ if (getChannel() != null)
+ getChannel().close ();
closed = true;
}
@@ -351,7 +338,7 @@
*/
public ServerSocketChannel getChannel()
{
- return ch;
+ return null;
}
/**
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.27
diff -u -b -B -r1.27 Socket.java
--- java/net/Socket.java 10 Sep 2003 17:39:18 -0000 1.27
+++ java/net/Socket.java 18 Sep 2003 11:30:40 -0000
@@ -87,8 +87,6 @@
private boolean inputShutdown = false;
private boolean outputShutdown = false;
- SocketChannel ch; // this field must have been set if created by SocketChannel
-
private boolean closed = false;
/**
@@ -298,15 +296,6 @@
// that default. JDK 1.2 doc infers not to do a bind.
}
- /*
- * This method may only be used by java.nio.channels.ServerSocketChannel.accept and
- * java.nio.channels.SocketChannel.open.
- */
- void setChannel (SocketChannel ch)
- {
- this.ch = ch;
- }
-
/**
* Binds the socket to the givent local address/port
*
@@ -401,7 +390,8 @@
if (! (endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException ("Address type not supported");
- if (ch != null && !ch.isBlocking ())
+ if (getChannel() != null
+ && !getChannel().isBlocking ())
throw new IllegalBlockingModeException ();
if (!isBound ())
@@ -882,8 +872,8 @@
if (impl != null)
impl.close();
- if (ch != null)
- ch.close();
+ if (getChannel() != null)
+ getChannel().close();
closed = true;
}
@@ -970,7 +960,7 @@
*/
public SocketChannel getChannel()
{
- return ch;
+ return null;
}
/**