std::vector<std::unique_ptr<Group> > Group::ConstructLoopbackMesh( size_t num_hosts) { // construct a group of num_hosts std::vector<std::unique_ptr<Group> > group(num_hosts); for (size_t i = 0; i < num_hosts; ++i) { group[i] = std::make_unique<Group>(i, num_hosts); } // construct a stream socket pair for (i,j) with i < j for (size_t i = 0; i != num_hosts; ++i) { for (size_t j = i + 1; j < num_hosts; ++j) { LOG << "doing Socket::CreatePair() for i=" << i << " j=" << j; std::pair<Socket, Socket> sp = Socket::CreatePair(); group[i]->connections_[j] = Connection(std::move(sp.first)); group[j]->connections_[i] = Connection(std::move(sp.second)); group[i]->connections_[j].is_loopback_ = true; group[j]->connections_[i].is_loopback_ = true; } } return group; }
/** Parses the PTPIP header, gets and validates that the packet type is correct and sets the value of the packet length. @return Type The PTPIP packet type received ie event or cancel. In case of invalid type, it returns 0 */ TInt CPTPIPEventHandler::ParsePTPIPHeaderL() { OstTraceFunctionEntry0( CPTPIPEVENTHANDLER_PARSEPTPIPHEADERL_ENTRY ); TUint32 type = Connection().ValidateAndSetEventPayloadL(); iPTPPacketLength = Connection().EventContainer()->Uint32L(CPTPIPGenericContainer::EPacketLength); OstTraceFunctionExit0( CPTPIPEVENTHANDLER_PARSEPTPIPHEADERL_EXIT ); return type; }
void SkyBoxConnector::keyPress(char key) { if(SCENE->camera->GetTarget() == (IGObject*)this->Connection()) { if(key>='0' && key<'9') { if(lastKey!=key) { current=(key-48>=0 && key-48<=5)? key-48 : 6; printf("SKYBOX: sellected wall: %s\n", wallNames[current]); } lastKey=key; } else if(key=='l') { if(lastKey!='l') { ((SkyBox*)Connection())->LoadeHightMap(files[currentSellection],bumpmapchannel,current>5? -1:current); if(++bumpmapchannel>3) bumpmapchannel=0; } lastKey='l'; } else if(key=='x') { if(lastKey!='x') { currentSellection=currentSellection==5?0:currentSellection+1; printf("Sellected Image: %s\n",files[currentSellection]); } lastKey='x'; } else if(key=='r') { if(lastKey!='r') { ((SkyBox*)Connection())->LoadeColorMap(files[currentSellection],current>5? -1:current); } lastKey='r'; } else for(int i=0;i<6;i++) { current = i; vConnection()->Get<VoxControl>()->keyPress(key); } } }
/** Called during the PTP connection establishment phase to mark the completion of sending the init ack to the initiator @return Flag stating that the ini has been sent successfully. */ TBool CPTPIPEventHandler::HandleInitAck() { OstTraceFunctionEntry0( CPTPIPEVENTHANDLER_HANDLEINITACK_ENTRY ); TBool isHandled(EFalse); if (iState == EInitSendInProgress) { //Now signal the connection, set its state and set it to active. Connection().SetConnectionState(CPTPIPConnection::EInitialisationComplete); Connection().CompleteSelf(iStatus.Int()); iState = EIdle; isHandled = ETrue; } OstTraceFunctionExit0( CPTPIPEVENTHANDLER_HANDLEINITACK_EXIT ); return isHandled; }
static void BasicTest() { // Replace this URL with your own URL: XmlRpcClient Connection("http://web.edval.com.au/rpc"); Connection.setIgnoreCertificateAuthority(); //Connection.setBasicAuth_Callback(PopUpAPrettyDialog); Connection.setBasicAuth_UsernameAndPassword("foo", "goo"); // Call: arumate.getKilowatts(string, integer) : XmlRpcValue args, result; args[0] = "test"; args[1] = 1; // double g = 3.14159; XmlRpcValue binary(&g, sizeof(g)); args[2] = binary; XmlRpcValue::BinaryData bdata = binary; // Replace this function name with your own: if (! Connection.execute("getKilowatts", args, result)) { std::cout << Connection.getError(); } else if (result.getType() == XmlRpcValue::TypeString) std::cout << result.GetStdString(); else std::cout << "Success\n"; }
Neuron::Neuron(unsigned numberOutputs, unsigned index, const string &transferFunction) { for (unsigned c = 0; c < numberOutputs; c++) { outputWeights.push_back(Connection()); } this->index=index; this->transferFunction=transferFunction; }
void ConnectionManager::addConnection(SIN& addr) { std::map<SIN, Connection>::iterator it; if ((it = conn_map.find(addr)) == conn_map.end()) conn_map.insert(ConnectionRecord(addr, Connection(parent, *this, addr))); else throw CONN_DUP; }
const std::vector<std::string> Environment::ScanPorts() const { std::vector<std::string> validNames; std::string portName; for(unsigned int i = 1; i < 17; i++) { portName = "Com"; portName.append( boost::lexical_cast<std::string>(i)); #ifdef SERIALCONNECTION_DEBUG std::cout << "Trying port name: " << portName << "..."; #endif // SERIALCONNECTION_DEBUG SerialDeviceEnumeration Enum(portName, 9600); SerialConnection Connection(io_service, Enum); if( !Connection.Connect() ) { #ifdef SERIALCONNECTION_DEBUG std::cout << "valid.\n"; #endif // SERIALCONNECTION_DEBUG validNames.push_back(portName); } else { #ifdef SERIALCONNECTION_DEBUG std::cout << "invalid.\n"; #endif // SERIALCONNECTION_DEBUG } Connection.Disconnect(); } return validNames; }
Connection Signal<_Res (_ArgTypes...), Combiner>::connect(const SlotType& _slot) { auto newConnectionBody = std::make_shared<ConnectionBodyType>(_slot); mConnectionBodies.insert(newConnectionBody); return Connection(std::move(newConnectionBody)); }
void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL ) return; NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPath = *aSheetPath; item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Type = NET_LABEL; if( GetLayer() == LAYER_GLOBLABEL ) item->m_Type = NET_GLOBLABEL; else if( GetLayer() == LAYER_HIERLABEL ) item->m_Type = NET_HIERLABEL; item->m_Label = m_Text; item->m_Start = item->m_End = GetTextPos(); aNetListItems.push_back( item ); // If a bus connects to label if( Connection( *aSheetPath )->IsBusLabel( m_Text ) ) { item->ConvertBusToNetListItems( aNetListItems ); } }
int main(int argc, char *argv[]) { int sock, x = 0; char *Path = argv[1], *Pro_Sea = argv[2], *Host = argv[3]; puts("[+] NsT-phpBBDoS v0.1 by HaCkZaTaN"); puts("[+] NeoSecurityTeam"); puts("[+] Dos has begun....[+]\n"); fflush(stdout); if(argc != 4) Use(argv[0]); while(1) { sock = Connection(Host,80); Write_In(sock, Path, Pro_Sea, Host, x); #ifndef WIN32 shutdown(sock, SHUT_WR); close(sock); #else closesocket(sock); WSACleanup(); #endif Pro_Sea = argv[2]; x++; } //I don't think that it will get here =) return 0; }
nsresult TLSFilterTransaction::ReadSegments(nsAHttpSegmentReader *aReader, uint32_t aCount, uint32_t *outCountRead) { MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); LOG(("TLSFilterTransaction::ReadSegments %p max=%d\n", this, aCount)); if (!mTransaction) { return NS_ERROR_UNEXPECTED; } mReadSegmentBlocked = false; mSegmentReader = aReader; nsresult rv = mTransaction->ReadSegments(this, aCount, outCountRead); LOG(("TLSFilterTransaction %p called trans->ReadSegments rv=%x %d\n", this, rv, *outCountRead)); if (NS_SUCCEEDED(rv) && mReadSegmentBlocked) { rv = NS_BASE_STREAM_WOULD_BLOCK; LOG(("TLSFilterTransaction %p read segment blocked found rv=%x\n", this, rv)); Connection()->ForceSend(); } return rv; }
/****************************************************************************** * Disconnect from the timer. The timer is stopped if no longer needed. */ void SynchTimer::disconnecT(QObject* receiver, const char* member) { if (mTimer) { mTimer->disconnect(receiver, member); if (member) { int i = mConnections.indexOf(Connection(receiver, member)); if (i >= 0) mConnections.removeAt(i); } else { for (int i = 0; i < mConnections.count(); ) { if (mConnections[i].receiver == receiver) mConnections.removeAt(i); else ++i; } } if (mConnections.isEmpty()) { mTimer->disconnect(); mTimer->stop(); } } }
/** Sends a response to the initiator. @param aCode MTP response code */ void CMTPGetObjectPropsSupported::SendResponseL(TUint16 aCode) { const TMTPTypeRequest& req(Request()); iResponse.SetUint16(TMTPTypeResponse::EResponseCode, aCode); iResponse.SetUint32(TMTPTypeResponse::EResponseSessionID, req.Uint32(TMTPTypeRequest::ERequestSessionID)); iResponse.SetUint32(TMTPTypeResponse::EResponseTransactionID, req.Uint32(TMTPTypeRequest::ERequestTransactionID)); iFramework.SendResponseL(iResponse, req, Connection()); }
Connection Signal<void (_ArgTypes...)>::connect(SlotType&& _slot) { auto newConnectionBody = std::make_shared<ConnectionBodyType>(std::forward<SlotType>(_slot)); mConnectionBodies.insert(newConnectionBody); return Connection(std::move(newConnectionBody)); }
bool MysqlCon::CheckConnection() { if (NULL == m_mysql) { return Connection(); } return m_isConnect; }
Neuron::Neuron(unsigned numOutputs, unsigned myIndex) { for (unsigned c = 0; c < numOutputs; ++c) { m_outputWeights.push_back(Connection()); m_outputWeights.back().weight = randomWeight(); } m_myIndex = myIndex; }
Connection SignalLinkBase::connect(const Wt::Core::observable *object) { assert (!connected_); connected_ = true; obj_.reset(object); return Connection(this); }
GuiGraphicsView::GuiGraphicsView(const CRect& size, const int& numberOfModules, CBaseObject* editor) : CViewContainer(size), numberOfModules(numberOfModules), editor(editor) { modules.resize(numberOfModules); connections = new GuiGraphicsConnections(size, numberOfModules); connections->setMouseEnabled(false); this->addView(connections); drawnConnection = Connection(); moduleClicked = 0; }
Connection Connection::create(Engine engine) { ib_conn_t* ib_conn; Internal::throw_if_error( ib_conn_create(engine.ib(), &ib_conn, NULL) ); return Connection(ib_conn); }
Neuron::Neuron( unsigned numOutputs, unsigned weightIndex ) { for( unsigned c = 0; c < numOutputs; ++c ) { _outputWeights.push_back( Connection() ); _outputWeights.back().setWeight( randomWeight() ); } _weightIndex = weightIndex; }
Connection Collection::connectPostChanged(ElementPostChangedCallback callback) { if (impl_) { return impl_->connectPostChanged(callback); } else { return Connection(); } }
Connection Collection::connectPreChange(ElementPreChangeCallback callback) { if (impl_) { return impl_->connectPreChange(callback); } else { return Connection(); } }
Connection Collection::connectPostInserted(ElementRangeCallback callback) { if (impl_) { return impl_->connectPostInserted(callback); } else { return Connection(); } }
int Client::connect(const InetAddress& addr) { if (mEpoller == NULL || mLoop == NULL || mSock == NULL) { FATAL_LOG("new obj failed"); return false; } mEpoller->createEpoll(); mConnection = NEW Connection(mSock, mLoop); mEpoller->addRW(mConnection); return mSock->connect(addr); }
static void AdvancedTest() { XmlRpcValue args, result; // Passing datums: args[0] = "a string"; args[1] = 1; args[2] = true; args[3] = 3.14159; struct tm timeNow; args[4] = XmlRpcValue(&timeNow); // Passing an array: XmlRpcValue array; array[0] = 4; array[1] = 5; array[2] = 6; args[5] = array; // Note: if there's a chance that the array contains zero elements, // you'll need to call: // array.initAsArray(); // ...because otherwise the type will never get set to "TypeArray" and // the value will be a "TypeInvalid". // Passing a struct: XmlRpcValue record; record["SOURCE"] = "a"; record["DESTINATION"] = "b"; record["LENGTH"] = 5; args[6] = record; // We don't support zero-size struct's...Surely no-one needs these? // Make the call: XmlRpcClient Connection("https://61.95.191.232:9600/arumate/rpc/xmlRpcServer.php"); Connection.setIgnoreCertificateAuthority(); if (! Connection.execute("arumate.getMegawatts", args, result)) { std::cout << Connection.getError(); return; } // Pull the data out: if (result.getType() != XmlRpcValue::TypeStruct) { std::cout << "I was expecting a struct."; return; } int i = result["n"]; std::string s = result["name"]; array = result["A"]; for (int i=0; i < array.size(); i++) std::cout << (int)array[i] << "\n"; record = result["subStruct"]; std::cout << (std::string)record["foo"] << "\n"; }
Try<Connection> MockCSIPlugin::startup(const Option<string>& address) { ServerBuilder builder; if (address.isSome()) { builder.AddListeningPort(address.get(), InsecureServerCredentials()); } builder.RegisterService(static_cast<Identity::Service*>(this)); builder.RegisterService(static_cast<Controller::Service*>(this)); builder.RegisterService(static_cast<Node::Service*>(this)); server = builder.BuildAndStart(); if (!server) { return Error("Unable to start a mock CSI plugin."); } return address.isSome() ? Connection(address.get()) : Connection(server->InProcessChannel(ChannelArguments())); }
//--------------------------------------------------------------------------- void WtBroadcastServer::Connect( WtBroadcastServerClient * const client, const boost::function<void()>& function) { std::lock_guard<std::mutex> lock(m_mutex); m_connections.push_back( Connection( Wt::WApplication::instance()->sessionId(), client, function)); }
void DataManipulationForm::retrievePKColumns(const QString &schema, const QString &table) { Catalog catalog; Connection conn=Connection(tmpl_conn_params); try { vector<attribs_map> pks; ObjectType obj_type=static_cast<ObjectType>(table_cmb->currentData().toUInt()); if(obj_type==OBJ_VIEW) { warning_frm->setVisible(true); warning_lbl->setText(trUtf8("Views can't have their data handled through this grid, this way, all operations are disabled.")); } else { catalog.setConnection(conn); //Retrieving the constraints from catalog using a custom filter to select only primary keys (contype=p) pks=catalog.getObjectsAttributes(OBJ_CONSTRAINT, schema, table, {}, {{ParsersAttributes::CUSTOM_FILTER, QString("contype='p'")}}); catalog.closeConnection(); warning_frm->setVisible(pks.empty()); if(pks.empty()) warning_lbl->setText(trUtf8("The selected table doesn't owns a primary key! Updates and deletes will be performed by considering all columns as primary key. <strong>WARNING:</strong> those operations can affect more than one row.")); } hint_frm->setVisible(obj_type==OBJ_TABLE); add_tb->setEnabled(obj_type==OBJ_TABLE); pk_col_ids.clear(); if(!pks.empty()) { QStringList col_str_ids=Catalog::parseArrayValues(pks[0][ParsersAttributes::COLUMNS]); for(QString id : col_str_ids) pk_col_ids.push_back(id.toInt() - 1); } //For tables, even if there is no pk the user can manipulate data if(obj_type==OBJ_TABLE) results_tbw->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::AnyKeyPressed); else results_tbw->setEditTriggers(QAbstractItemView::NoEditTriggers); } catch(Exception &e) { catalog.closeConnection(); throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }
void DataManipulationForm::listObjects(QComboBox *combo, vector<ObjectType> obj_types, const QString &schema) { Catalog catalog; Connection conn=Connection(tmpl_conn_params); try { attribs_map objects; QStringList items; int idx=0, count=0; catalog.setConnection(conn); catalog.setFilter(Catalog::LIST_ALL_OBJS); combo->blockSignals(true); combo->clear(); for(auto &obj_type : obj_types) { objects=catalog.getObjectsNames(obj_type, schema); for(auto &attr : objects) items.push_back(attr.second); items.sort(); combo->addItems(items); count+=items.size(); items.clear(); for(; idx < count; idx++) { combo->setItemIcon(idx, QPixmap(QString(":/icones/icones/") + BaseObject::getSchemaName(obj_type) + QString(".png"))); combo->setItemData(idx, obj_type); } idx=count; } if(combo->count()==0) combo->insertItem(0, trUtf8("No objects found")); else combo->insertItem(0, trUtf8("Found %1 object(s)").arg(combo->count())); combo->setCurrentIndex(0); combo->blockSignals(false); catalog.closeConnection(); } catch(Exception &e) { catalog.closeConnection(); throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e); } }