From c7fc4734b8f27892cd901134c486a42a599de60c Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Thu, 15 Mar 2007 02:53:01 +0000 Subject: [PATCH] Added ability to get the local network address that connects to the server. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7525 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/XMPPConnection.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java index d6d3e5f76..d0cd0c2aa 100644 --- a/source/org/jivesoftware/smack/XMPPConnection.java +++ b/source/org/jivesoftware/smack/XMPPConnection.java @@ -34,6 +34,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.Socket; import java.net.UnknownHostException; +import java.net.InetAddress; import java.util.Collection; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; @@ -532,6 +533,19 @@ public class XMPPConnection { return isUsingTLS(); } + /** + * Returns the local network address of the socket used to connect to the server, or + * null if not currently connected to the server. + * + * @return the local address for the socket used to connect to the server. + */ + public InetAddress getLocalNetworkAddress() { + if (socket == null || !socket.isConnected()) { + return null; + } + return socket.getLocalAddress(); + } + /** * Returns true if currently authenticated by successfully calling the login method. *