Package org.jivesoftware.smack.util.dns

Examples of org.jivesoftware.smack.util.dns.HostAddress


        Iterator<HostAddress> it = config.getHostAddresses().iterator();
        List<HostAddress> failedAddresses = new LinkedList<HostAddress>();
        boolean xmppIOError = false;
        while (it.hasNext()) {
            exception = null;
            HostAddress hostAddress = it.next();
            String host = hostAddress.getFQDN();
            int port = hostAddress.getPort();
            try {
                if (config.getSocketFactory() == null) {
                    this.socket = new Socket(host, port);
                }
                else {
                    this.socket = config.getSocketFactory().createSocket(host, port);
                }
            } catch (UnknownHostException uhe) {
                String errorMessage = "Could not connect to " + host + ":" + port + ".";
                exception = new XMPPException(errorMessage, new XMPPError(XMPPError.Condition.remote_server_timeout,
                        errorMessage), uhe);
            } catch (IOException ioe) {
                String errorMessage = "XMPPError connecting to " + host + ":" + port + ".";
                exception = new XMPPException(errorMessage, new XMPPError(XMPPError.Condition.remote_server_error,
                        errorMessage), ioe);
                xmppIOError = true;
            }
            if (exception == null) {
                // We found a host to connect to, break here
                config.setUsedHostAddress(hostAddress);
                break;
            }
            hostAddress.setException(exception);
            failedAddresses.add(hostAddress);
            if (!it.hasNext()) {
                // There are no more host addresses to try
                // throw an exception and report all tried
                // HostAddresses in the exception
View Full Code Here


        this.resource = resource;
    }

    private void initHostAddresses(String host, int port) {
        hostAddresses = new ArrayList<HostAddress>(1);
        HostAddress hostAddress;
        try {
             hostAddress = new HostAddress(host, port);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        hostAddresses.add(hostAddress);
    }
View Full Code Here

     *      XMPP server can be reached at for the specified domain.
     */
    public static List<HostAddress> resolveXMPPDomain(final String domain) {
        if (dnsResolver == null) {
            List<HostAddress> addresses = new ArrayList<HostAddress>(1);
            addresses.add(new HostAddress(domain, 5222));
            return addresses;
        }
        return resolveDomain(domain, 'c');
    }
View Full Code Here

     *      XMPP server can be reached at for the specified domain.
     */
    public static List<HostAddress> resolveXMPPServerDomain(final String domain) {
        if (dnsResolver == null) {
            List<HostAddress> addresses = new ArrayList<HostAddress>(1);
            addresses.add(new HostAddress(domain, 5269));
            return addresses;
        }
        return resolveDomain(domain, 's');
    }
View Full Code Here

        List<HostAddress> sortedRecords = sortSRVRecords(srvRecords);
        if (sortedRecords != null)
            addresses.addAll(sortedRecords);

        // Step two: Add the hostname to the end of the list
        addresses.add(new HostAddress(domain));

        // Add item to cache.
        cache.put(key, addresses);

        return addresses;
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.util.dns.HostAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.