net_handle_t ClientConn::connect(const string& strIp, uint16_t nPort, const string& strName, const string& strPass) { m_handle = netlib_connect(strIp.c_str(), nPort, imconn_callback, &g_client_conn_map); if(m_handle != NETLIB_INVALID_HANDLE) g_client_conn_map.insert(make_pair(m_handle, this)); return m_handle; }
net_handle_t ClientConn::connect(const string& strIp, uint16_t nPort, const string& strName, const string& strPass) { m_handle = netlib_connect(strIp.c_str(), nPort, imconn_callback, &m_connMap); m_connMap[m_handle] = this; return m_handle; }
void CRouteServConn::Connect(const char* server_ip, uint16_t server_port, uint32_t idx) { log("Connecting to RouteServer %s:%d\n", server_ip, server_port); m_serv_idx = idx; m_handle = netlib_connect(server_ip, server_port, imconn_callback, (void*)&g_route_server_conn_map); if (m_handle != NETLIB_INVALID_HANDLE) { g_route_server_conn_map.insert(make_pair(m_handle, this)); } }
net_handle_t CImConn::Connect(const char* server_ip, uint16_t server_port) { m_handle = netlib_connect(server_ip, server_port, imconn_callback, 0); return m_handle; }
/* **++ ** ROUTINE: do_connect ** ** FUNCTIONAL DESCRIPTION: ** ** Completion routine for NETLIB_CONNECT_BY_NAME. Can be ** invoked as a regular main-line routine or an AST completion. ** ** RETURNS: cond_value, longword (unsigned), write only, by value ** ** PROTOTYPE: ** ** DO_CONNECT connection-context ** ** IMPLICIT INPUTS: None. ** ** IMPLICIT OUTPUTS: None. ** ** COMPLETION CODES: Any NETLIB network status code. ** ** SIDE EFFECTS: None. ** **-- */ static unsigned int do_connect (struct Connect_Context *con) { unsigned int status; int done; /* ** We implement our FSM as a loop for the synchronous case */ done = 0; while (!done) { status = con->iosb.iosb_w_status; switch (con->state) { /* ** Initial state -- if the DNS lookup failed, fall back on host table ** entry. Otherwise, start trying the connections. */ case 0: if (con->nsadrcnt == 0) { if (con->htadrcnt == 0) { con->iosb.iosb_w_status = SS$_ENDOFFILE; done = 1; break; } con->adrlst = con->htadrlst; con->adrcnt = con->htadrcnt; } else { con->adrlst = con->nsadrlst; con->adrcnt = con->nsadrcnt; } con->state = 1; /* and fall through */ /* ** State 1: Attempt a connection */ case 1: con->sin.sin_x_addr = con->adrlst[con->curadr++]; con->state = 2; status = netlib_connect(&con->ctx, &con->sin, &sinsize, &con->iosb, (con->astadr == 0) ? 0 : do_connect, (con->astadr == 0) ? 0 : con); if (!OK(status)) done = 1; else if (con->astadr != 0) return status; break; /* ** State 2: connect() completion status check. If we're successful ** or we've run out of addresses, we're done. Otherwise, we loop ** back up and try again. */ case 2: if (OK(status) || con->curadr >= con->adrcnt) done = 1; con->state = 1; break; } } /* ** We're done, one way or another. Fill in the caller's IOSB and ** call back the AST, if there was one. */ if (con->user_iosb != 0) memcpy(con->user_iosb, &con->iosb, sizeof(con->iosb)); if (con->astadr != 0) (*con->astadr)(con->astprm); /* ** We're done with this context -- free it */ lib$free_vm(&con->ctxsize, &con); /* ** Synchronous completion occurs here. */ return status; } /* do_connect */
net_handle_t CClientConn::connect(const string& strIp, uint16_t nPort, const string& strName, const string& strPass) { m_handle = netlib_connect(strIp.c_str(), nPort, imconn_callback, NULL); return m_handle; }