int DOwner::start_sender(const ACE_INET_Addr & remote) { ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, monitor, this->lock_, 0); if (this->connections_ >= MAX_CONNECTIONS || flg_cancel_ != 0) return -1; for (u_int i = 0; i < MAX_CONNECTIONS; ++i) { if (this->list_connections_ [i] == 0) { ACE_NEW_RETURN (this->list_connections_[i], Sender (*this, i), -1); this->list_connections_[i]->open(ACE_INET_Addr((u_short)0), remote); return 0; } } ACE_ASSERT(0); return -1; }
int main(int argc, char * argv[]) { try{ boost::scoped_ptr<WatchdogBridge> pServer ( new WatchdogBridge("WatchdogSM")); CliCommandParser p(argc,argv); CliCommandParser::CommandsArray commands = p.parse(); std::for_each( commands.begin(), commands.end(), Sender( pServer.get() ) ); if ( commands.empty() ) LOG( "Commands array is empty. No command given. Shouldn't happen" ); } catch( const boost::interprocess::interprocess_exception& ex) { LOG( " Exception what=" << ex.what() << " native error code=" << ex.get_native_error() << " err code=" << ex.get_error_code()); } return 0 ; }
int Connector::make_svc_handler (Sender * & sh) { ACE_Guard<ACE_Recursive_Thread_Mutex> locker (this->mutex_); if (sessions_ >= MAX_SENDERS) return -1; for (size_t i = 0; i < MAX_SENDERS; ++i) if (this->list_senders_ [i] == 0) { ACE_NEW_RETURN (sh, Sender (this , i), -1); return 0; } return -1; }
Sender * Connector::make_handler (void) { if (this->sessions_ >= SENDERS) return 0; for (int i = 0; i < SENDERS; ++i) { if (this->list_senders_ [i] == 0) { ACE_NEW_RETURN (this->list_senders_[i], Sender (this, i), 0); return this->list_senders_[i]; } } return 0; }
//----------------------------------------------------- // // MAIN // //----------------------------------------------------- int main(int argc, char *argv[]) { DWORD dwNumChars; int dDirectMode; if (argc != 2) { Syntax(); } // // Retrieve the computer name. // dwNumChars = MAX_COMPUTERNAME_LENGTH; if(!GetComputerName(mbsMachineName, &dwNumChars)) { printf("Failed to get computer name. Exiting...\n"); exit(1); } // // Detect a DS connection and determine the working mode. // dDirectMode = SetConnectionMode(); if(strcmp(argv[1], "-s") == 0) Sender(dDirectMode); else if (strcmp(argv[1], "-r") == 0) Receiver(dDirectMode); else Syntax(); printf("\nOK\n"); return(0); }
void CMQTTClient::Run (void) { while (1) { if (m_ConnectStatus != MQTTStatusDisconnected) { Receiver (); Sender (); KeepAliveHandler (); CScheduler::Get ()->MsSleep (50); } else { CScheduler::Get ()->MsSleep (200); } OnLoop (); } }
Sender::Sender(TCPSocket *socket) { string str(""); Sender(socket, str, 1000); }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; Sender *sender_impl = 0; ACE_NEW_RETURN (sender_impl, Sender (orb.in ()), 1); PortableServer::ServantBase_var receiver_owner_transfer(sender_impl); PortableServer::ObjectId_var id = root_poa->activate_object (sender_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Sender_var sender = Test::Sender::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (sender.in ()); // If the ior_output_file exists, output the ior to it FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); poa_manager->activate (); Server_Task server_task (orb.in (), sender_impl, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, "Now terminating test\n")); root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
/* Here comes the main function of your program */ int main(int argc, char **argv) { /* When your program starts, you have to first start a new simulation engine, as follows */ simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv); /* Then you should load a platform file, describing your simulated platform */ e->loadPlatform("../../platforms/small_platform.xml"); /* And now you have to ask SimGrid to actually start your actors. * * You can first directly start your actor, as follows. Note the last parameter: 'Sender()', * as if you would call the Sender function. */ simgrid::s4u::Actor::createActor("sender1", simgrid::s4u::Host::by_name("Tremblay"), Sender()); /* The second way is to first register your function, and then retrieve it */ e->registerFunction<Sender>("sender"); // The sender is passed as a template parameter here std::vector<std::string> args; // Here we declare the parameter that the actor will get args.push_back("GloubiBoulga"); // Add a parameter to the set (we could have done it in the first approach too) simgrid::s4u::Actor::createActor("sender2", simgrid::s4u::Host::by_name("Jupiter"), "sender", args); /* The third way to start your actors is to use a deployment file. */ e->registerFunction<Receiver>("receiver"); // You first have to register the actor as with the second approach e->loadDeployment("deployment.xml"); // And then, you load the deployment file /* Once every actors are started in the engine, the simulation can start */ e->run(); /* Once the simulation is done, the program is ended */ return 0; }
int main(int argc, char* argv[]) { float result; int I; if(argc < 2) { fprintf(stderr,"Supply data set file.\n"); return(1); } FILE* fp = fopen(argv[1],"r"); if(fp == NULL) { fprintf(stderr,"Could not open data set file %s.\n", argv[1]); return(1); } signal(SIGINT, Exit); signal(SIGTERM, Exit); PTHREAD_DECL(Logger); PTHREAD_CREATE(Logger); #ifdef SW init_pipe_handler(); PTHREAD_DECL(bestFit); PTHREAD_CREATE(bestFit); #endif Sender(); for(I = 0; I < NSAMPLES; I++) { double X; fscanf(fp, "%le", &X); write_float64("sample_data_pipe", X); samples[I] = X; } fprintf(stderr," Sent samples.\n"); fclose(fp); calculateReferenceFit(); uint32_t best_sigma_index = read_uint32("best_sigma_pipe"); fprintf(stdout, " Best sigma= %f (index = %d).\n", (MIN_SIGMA + (best_sigma_index*(MAX_SIGMA - MIN_SIGMA)/NSIGMAS)), best_sigma_index); double p0 = read_float64("fit_coefficient_pipe"); double p1 = read_float64("fit_coefficient_pipe"); double p2 = read_float64("fit_coefficient_pipe"); double p3 = read_float64("fit_coefficient_pipe"); double p4 = read_float64("fit_coefficient_pipe"); double p5 = read_float64("fit_coefficient_pipe"); fprintf(stdout, "Fit coefficients = %le, %le, %le, %le, %le, %le.\n", p0,p1,p2,p3,p4,p5); uint32_t elapsed_time = read_uint32("elapsed_time_pipe"); fprintf(stdout,"Elapsed time = %d.\n", elapsed_time); #ifdef SW PTHREAD_CANCEL(bestFit); close_pipe_handler(); return(0); #endif }
void RetransmissionProtocol::Simulate(bool nak) { Sender(nak); }