src/main/java/org/jivesoftware/smack/PacketReader.java
synchronized public void startup() throws XMPPException {
        final List<Exception> errors = new LinkedList<Exception>();
        AbstractConnectionListener connectionErrorListener = new AbstractConnectionListener() {
            @Override
            public void connectionClosedOnError(Exception e) {
                errors.add(e);
            }
        };
        connection.addConnectionListener(connectionErrorListener);

        readerThread.start();
        // Wait for stream tag before returning. We'll wait a couple of seconds
        // before
        // giving up and throwing an error.
        try {
            // A waiting thread may be woken up before the wait time or a notify
            // (although this is a rare thing). Therefore, we continue waiting
            // until either a connectionID has been set (and hence a notify was
            // made) or the total wait time has elapsed.
            int waitTime = SmackConfiguration.getPacketReplyTimeout();
            wait(3 * waitTime);
        } catch (InterruptedException ie) {
            // Ignore.
        }

        connection.removeConnectionListener(connectionErrorListener);

        if (connectionID == null) {
            throw new XMPPException(
                    "Connection failed. No response from server.");
        } else if (!errors.isEmpty()) {
            throw new XMPPException(errors.iterator().next());
        } else {
            connection.connectionID = connectionID;
        }
    }
synchronized public void startup() throws XMPPException {
        final List<Exception> errors = new LinkedList<Exception>();
        AbstractConnectionListener connectionErrorListener = new AbstractConnectionListener() {
            @Override
            public void connectionClosedOnError(Exception e) {
                errors.add(e);
            }
        };
        connection.addConnectionListener(connectionErrorListener);

        readerThread.start();
        // Wait for stream tag before returning. We'll wait a couple of seconds
        // before
        // giving up and throwing an error.
        try {
            // A waiting thread may be woken up before the wait time or a notify
            // (although this is a rare thing). Therefore, we continue waiting
            // until either a connectionID has been set (and hence a notify was
            // made) or the total wait time has elapsed.
            int waitTime = SmackConfiguration.getPacketReplyTimeout();
            wait(3 * waitTime);
        } catch (InterruptedException ie) {
            // Ignore.
        }

        connection.removeConnectionListener(connectionErrorListener);

        if (connectionID == null) {
            throw new XMPPException(
                    "Connection failed. No response from server.");
        } else if (!errors.isEmpty()) {
            throw new XMPPException(errors.iterator().next());
        } else {
            connection.connectionID = connectionID;
        }
    }
synchronized public void startup ( ) throws XMPPException { final List < Exception > errors = new LinkedList < Exception > ( ) ; AbstractConnectionListener connectionErrorListener = new AbstractConnectionListener ( ) { @ Override public void connectionClosedOnError ( Exception e ) { errors . add ( e ) ; } } ; connection . addConnectionListener ( connectionErrorListener ) ; readerThread . start ( ) ; // Wait for stream tag before returning. We'll wait a couple of seconds // before // giving up and throwing an error. try { // A waiting thread may be woken up before the wait time or a notify // (although this is a rare thing). Therefore, we continue waiting // until either a connectionID has been set (and hence a notify was // made) or the total wait time has elapsed. int waitTime = SmackConfiguration . getPacketReplyTimeout ( ) ; wait ( 3 * waitTime ) ; } catch ( InterruptedException ie ) { // Ignore. } connection . removeConnectionListener ( connectionErrorListener ) ; if ( connectionID == null ) { throw new XMPPException ( "Connection failed. No response from server." ) ; } else if ( ! errors . isEmpty ( ) ) { throw new XMPPException ( errors . iterator ( ) . next ( ) ) ; } else { connection . connectionID = connectionID ; } }
Starts the packet reader thread and returns once a connection to the
server has been established. A connection will be attempted for a maximum
of five seconds. An XMPPException will be thrown if the connection fails.

@throws XMPPException
if the server fails to send an opening stream back for more
than five seconds.
Starts the packet reader thread and returns once a connection to the server has been established . A connection will be attempted for a maximum of five seconds . An XMPPException will be thrown if the connection fails .