private ErrorCode sendConnectProtocol(long to) {
        String sessId = session.id;
        ErrorCode ec = ErrorCode.OK;

        ConnectProtocol conReq = new ConnectProtocol(0, lastDxid,
                session.timeOut, sessId, session.password, authData.userName, authData.secret, authData.obfuscated);
        ServiceDirectoryFuture future = submitAsyncRequest(new ProtocolHeader(0, ProtocolType.CreateSession), conReq, null);

        try {
            ConnectResponse resp = null;
            if (future.isDone()) {
                resp = (ConnectResponse) future.get();
            } else {
                resp = (ConnectResponse) future.get(to, TimeUnit.MILLISECONDS);
            }
            onConnected(resp.getTimeOut(), resp.getSessionId(), resp.getPasswd(), resp.getServerId());
            return ec;
        } catch (ExecutionException e) {
            // ConnectResponse failed, renew session.
            ServiceException se = (ServiceException) e.getCause();
            ec = se.getServiceDirectoryError().getExceptionCode();

        } catch (Exception e) {
            ec = ErrorCode.GENERAL_ERROR;
        }
        future.cancel(false);
        return ec;
    }
private ErrorCode sendConnectProtocol ( long to ) { String sessId = session . id ; ErrorCode ec = ErrorCode . OK ; ConnectProtocol conReq = new ConnectProtocol ( 0 , lastDxid , session . timeOut , sessId , session . password , authData . userName , authData . secret , authData . obfuscated ) ; ServiceDirectoryFuture future = submitAsyncRequest ( new ProtocolHeader ( 0 , ProtocolType . CreateSession ) , conReq , null ) ; try { ConnectResponse resp = null ; if ( future . isDone ( ) ) { resp = ( ConnectResponse ) future . get ( ) ; } else { resp = ( ConnectResponse ) future . get ( to , TimeUnit . MILLISECONDS ) ; } onConnected ( resp . getTimeOut ( ) , resp . getSessionId ( ) , resp . getPasswd ( ) , resp . getServerId ( ) ) ; return ec ; } catch ( ExecutionException e ) { ServiceException se = ( ServiceException ) e . getCause ( ) ; ec = se . getServiceDirectoryError ( ) . getExceptionCode ( ) ; } catch ( Exception e ) { ec = ErrorCode . GENERAL_ERROR ; } future . cancel ( false ) ; return ec ; }
Send the Connect Protocol to the remote Directory Server.

@param to
the connection timeout.
@return
the ErrorCode of the request, OK for success.