From c378329b8c1a7a5376a8a3fb71528f806936eef1 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Tue, 29 Nov 2016 10:53:03 -0600 Subject: [PATCH] feat: Returns the known socket address for sockets from the single-port mode. --- .../ice/harvest/AbstractUdpListener.java | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ice4j/ice/harvest/AbstractUdpListener.java b/src/main/java/org/ice4j/ice/harvest/AbstractUdpListener.java index 3ef9840..ddab37e 100644 --- a/src/main/java/org/ice4j/ice/harvest/AbstractUdpListener.java +++ b/src/main/java/org/ice4j/ice/harvest/AbstractUdpListener.java @@ -391,7 +391,7 @@ public abstract class AbstractUdpListener /** * The remote address that is associated with this socket. */ - private SocketAddress remoteAddress; + private InetSocketAddress remoteAddress; /** * The flag which indicates that this DatagramSocket has been @@ -406,7 +406,7 @@ public abstract class AbstractUdpListener * new instance. * @throws SocketException */ - public MySocket(SocketAddress remoteAddress) + MySocket(InetSocketAddress remoteAddress) throws SocketException { // unbound @@ -487,6 +487,45 @@ public abstract class AbstractUdpListener return localAddress; } + /** + * {@inheritDoc} + *

+ * This {@link DatagramSocket} will only allow packets from the + * remote address that it has, so we consider it connected to this + * address. + */ + @Override + public SocketAddress getRemoteSocketAddress() + { + return remoteAddress; + } + + /** + * {@inheritDoc} + *

+ * This {@link DatagramSocket} will only allow packets from the + * remote address that it has, so we consider it connected to this + * address. + */ + @Override + public InetAddress getInetAddress() + { + return remoteAddress.getAddress(); + } + + /** + * {@inheritDoc} + *

+ * This {@link DatagramSocket} will only allow packets from the + * remote address that it has, so we consider it connected to this + * address. + */ + @Override + public int getPort() + { + return remoteAddress.getPort(); + } + /** * {@inheritDoc} *