void ChatCore::tryconnect(const QString& nickname, const QString& ip, const QString& port) { auto thread = new QThread(this); if (server != nullptr) { server->destroy_connection(); delete server; } server = new Server(nickname.toStdString(), ip.toStdString(), port.toInt()); // server->moveToThread(thread); connect(thread, SIGNAL(started()), server, SLOT(establish_connection())); connect(server, SIGNAL(connected()), this, SLOT(connection_established())); connect(server, SIGNAL(readyRead()), this, SLOT(message_received())); connect(server, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connection_failed(QAbstractSocket::SocketError))); connect(server, SIGNAL(stop_thread()), thread, SLOT(quit())); thread->start(); }
void delayed_node_plugin::connect() { my->client_connection = std::make_shared<fc::rpc::websocket_api_connection>(*my->client.connect(my->remote_endpoint)); my->database_api = my->client_connection->get_remote_api<steemit::app::database_api>(0); my->client_connection_closed = my->client_connection->closed.connect([this] { connection_failed(); }); }
void delayed_node_plugin::connect() { my->client_connection = std::make_shared<fc::rpc::websocket_api_connection>(*my->client.connect(my->remote_endpoint), GRAPHENE_NET_MAX_NESTED_OBJECTS); my->database_api = my->client_connection->get_remote_api<graphene::app::database_api>(0); my->client_connection_closed = my->client_connection->closed.connect([this] { connection_failed(); }); }
void delayed_node_plugin::plugin_startup() { fc::async([this]() { mainloop(); }); try { connect(); my->database_api->set_block_applied_callback([this]( const fc::variant& block_id ) { fc::from_variant( block_id, my->last_received_remote_head ); } ); return; } catch (const fc::exception& e) { elog("Error during connection: ${e}", ("e", e.to_detail_string())); } fc::async([this]{connection_failed();}); }
inline ::soci::session* connectToDataBase(std::string const& connection, DatabaseType dtype) { ::soci::session* output(0); if (dtype == DATABASE_UNKNOWN) { std::stringstream oss; oss << "Database connection type '" << dtype << "' is unknown or not configured"; throw soci_driver_error(oss.str()); } try { if (dtype == DATABASE_POSTGRESQL) output = new ::soci::session(::soci::postgresql, connection); } catch (::soci::soci_error const& e) { std::stringstream oss; oss << "Unable to connect to database with error '" << e.what() << "'"; throw connection_failed(oss.str()); } return output; }
pdal::drivers::oci::Connection connect() { std::string connection = m_options.getValueOrThrow<std::string>("connection"); if (connection.empty()) throw pdal_error("Oracle connection string empty! Unable to connect"); std::string::size_type slash_pos = connection.find("/",0); std::string username = connection.substr(0,slash_pos); std::string::size_type at_pos = connection.find("@",slash_pos); std::string password = connection.substr(slash_pos+1, at_pos-slash_pos-1); std::string instance = connection.substr(at_pos+1); Connection con = boost::make_shared<OWConnection>(username.c_str(),password.c_str(),instance.c_str()); if (!con->Succeeded()) { throw connection_failed("Oracle connection failed"); } return con; }
//-------------------------------------------------------------------------- bool rpc_debmod_t::open_remote(const char *hostname, int port_number, const char *password) { rpc_packet_t *rp = NULL; irs = init_client_irs(hostname, port_number); if (irs == NULL) { failed: connection_failed(rp); return false; } rp = recv_request(PRF_DONT_POLL); if ( rp == NULL ) goto failed; if ( rp->code != RPC_OPEN ) // is this an ida debugger server? { connection_failed(rp); rpc_client_t::dwarning("ICON ERROR\nAUTOHIDE NONE\n" "Bogus remote server"); return false; } const uchar *answer = (uchar *)(rp+1); const uchar *end = answer + rp->length; int version = extract_long(&answer, end); int remote_debugger_id = extract_long(&answer, end); int easize = extract_long(&answer, end); qstring errstr; if ( version != IDD_INTERFACE_VERSION ) errstr.sprnt("protocol version is %d, expected %d", version, IDD_INTERFACE_VERSION); else if ( remote_debugger_id != debugger.id ) errstr.sprnt("debugger id is %d, expected %d (%s)", remote_debugger_id, debugger.id, debugger.name); else if ( easize != (inf.is_64bit() ? 8 : 4) ) errstr.sprnt("address size is %d bytes, expected %d", easize, inf.is_64bit() ? 8 : 4); if ( !errstr.empty() ) { connection_failed(rp); qstring cmd = prepare_rpc_packet(RPC_OK); append_long(cmd, false); send_request(cmd); warning("ICON ERROR\nAUTOHIDE NONE\n" "Incompatible debugging server:\n" "%s\n", errstr.c_str()); return false; } qfree(rp); qstring cmd = prepare_rpc_packet(RPC_OK); append_long(cmd, true); append_str(cmd, password); send_request(cmd); rp = recv_request(PRF_DONT_POLL); if ( rp == NULL || rp->code != RPC_OK ) goto failed; answer = (uchar *)(rp+1); end = answer + rp->length; bool password_ok = extract_long(&answer, end); if ( !password_ok ) // is this an ida debugger server? { connection_failed(rp); warning("ICON ERROR\nAUTOHIDE NONE\n" "Bad password"); return false; } qfree(rp); return true; }