Add DatagramChannel.isConnected()

.. because there is no way for a user with isActive to know if
   DatagramChannel is connected or not
This commit is contained in:
Trustin Lee 2012-06-19 10:43:38 +09:00
parent 9ec51d01d6
commit f60a6e861c
3 changed files with 12 additions and 0 deletions

View File

@ -35,6 +35,8 @@ public interface DatagramChannel extends Channel {
@Override @Override
InetSocketAddress remoteAddress(); InetSocketAddress remoteAddress();
boolean isConnected();
/** /**
* Joins a multicast group. * Joins a multicast group.
*/ */

View File

@ -112,6 +112,11 @@ public final class NioDatagramChannel
return ch.isOpen() && ch.socket().isBound(); return ch.isOpen() && ch.socket().isBound();
} }
@Override
public boolean isConnected() {
return javaChannel().isConnected();
}
@Override @Override
protected DatagramChannel javaChannel() { protected DatagramChannel javaChannel() {
return (DatagramChannel) super.javaChannel(); return (DatagramChannel) super.javaChannel();

View File

@ -109,6 +109,11 @@ public class OioDatagramChannel extends AbstractOioMessageChannel
return isOpen() && socket.isBound(); return isOpen() && socket.isBound();
} }
@Override
public boolean isConnected() {
return socket.isConnected();
}
@Override @Override
protected SocketAddress localAddress0() { protected SocketAddress localAddress0() {
return socket.getLocalSocketAddress(); return socket.getLocalSocketAddress();