Class SocketUtil


  • public class SocketUtil
    extends Object
    Utility class to generate Socket instances.
    Author:
    Guus der Kinderen, guus.der.kinderen@gmail.com
    • Constructor Detail

      • SocketUtil

        public SocketUtil()
    • Method Detail

      • createSocketToXmppDomain

        public static Map.Entry<Socket,​Boolean> createSocketToXmppDomain​(String xmppDomain,
                                                                               int port)
        Creates a socket connection to an XMPP domain. This implementation uses DNS SRV records to find a list of remote hosts for the XMPP domain (as implemented by DNSUtil.resolveXMPPDomain(String, int). It then iteratively tries to create a socket connection to each of them, until one socket connection succeeds. Either the connected Socket instance is returned, or null if no connection could be established. Note that this method blocks while performing network IO. The timeout as defined by RemoteServerManager.getSocketTimeout() is observed.
        Parameters:
        xmppDomain - The XMPP domain to connect to.
        port - The port to connect to when DNS resolution fails.
        Returns:
        a Socket instance that is connected, or null.
        See Also:
        DNSUtil.resolveXMPPDomain(String, int)