void CGameServDlg::OnCancel() { if (g_bNoExitConfirm) { StopServer(); CDialog::OnCancel(); return; } CString str, title; str.LoadString(IDS_CHECKEXIT); #ifdef _ADDON title.LoadString(IDS_APPNAME_AO); #else title.LoadString(IDS_APPNAME); #endif if (MessageBox(str, title, MB_YESNO | MB_ICONQUESTION) == IDYES) { StopServer(); CDialog::OnCancel(); } }
void QListenerThread::customEvent( QEvent *event ) { QThreadEvent* pEvent = ( QThreadEvent* ) event; QThreadEvent::EventType evtType = ( QThreadEvent::EventType ) pEvent->type( ); if ( QThreadEvent::EventStartListen == evtType ) { StopServer( ); StartServer( pEvent ); } else if ( QThreadEvent::EventStopListen == evtType ) { StopServer( ); } }
void Network::DeInit() { LOG(LogVerbose, "Network::DeInit: Closing down."); PolledTimer timer; // Kill all connections. while(connections.size() > 0) { MessageConnection *connection = *connections.begin(); CloseConnection(connection); // CloseConnection erases connection from the connections list, so this loop terminates. } // Kill the server, if it's running. StopServer(); // Kill all worker threads. while(workerThreads.size() > 0) CloseWorkerThread(workerThreads.front()); // Erases the item from workerThreads, so this loop terminates. // Clean up any sockets that might be remaining. while(sockets.size() > 0) { sockets.front().Close(); sockets.pop_front(); } // Deinitialize network subsystem. #ifdef WIN32 WSACleanup(); #endif LOG(LogWaits, "Network::DeInit: Deinitialized kNet Network object, took %f msecs.", timer.MSecsElapsed()); }
//--------------------------------------------------------------------------- void __fastcall TFtpServerForm::ImagesDblClick(TObject *Sender) { if (FtpServer1->Active) StopServer(); else StartServer(); }
void teRDNetwork::StartServer(u1 asClient, const c8 * connectToIP) { if(zmqContext) StopServer(); zmqContext = zmq_init(1); if(asClient) { c8 temp[256]; zmqCmd = zmq_socket(zmqContext, ZMQ_REQ); sprintf(temp, "tcp://%s:7748", connectToIP); zmq_connect(zmqCmd, temp); zmqDataDrop = zmq_socket(zmqContext, ZMQ_PULL); sprintf(temp, "tcp://%s:7749", connectToIP); zmq_connect(zmqDataDrop, temp); } else { zmqCmd = zmq_socket(zmqContext, ZMQ_REP); zmq_bind(zmqCmd, "tcp://*:7748"); zmqDataDrop = zmq_socket(zmqContext, ZMQ_PUSH); zmq_bind(zmqDataDrop, "tcp://*:7749"); } }
void MuHttpServer::stop(Subject &subject, const std::string &signal, const boost::any &v) { StopServer(); mSession.reset(NULL); mServerIsRunning = false; mpTimer->stop(); }
CTCPServer::~CTCPServer() { StopServer(); if (m_pTCPServer!=NULL) delete m_pTCPServer; m_pTCPServer=NULL; }
void main_exit() { StopServer(pMServer); pPacketQueue = NULL; pWrite = NULL; }
DatabaseMysql::~DatabaseMysql() { StopServer(); //Free Mysql library pointers for last ~DB if(--db_count == 0) mysql_library_end(); }
void CheckShutdown() { if (sGracefulShutdownInProgress) { QTSServerStatusRec theServerStatus; kern_return_t theErr = GetServerStatusRec(&theServerStatus); if ((theErr == SCNoError) && (theServerStatus.numCurrentConnections == 0)) theErr = StopServer(0); } }
/*---------------------------------------------------------------------- | CUPnP::~CUPnP +---------------------------------------------------------------------*/ CUPnP::~CUPnP() { m_UPnP->Stop(); StopClient(); StopServer(); delete m_UPnP; delete m_ServerHolder; delete m_RendererHolder; delete m_CtrlPointHolder; }
CTCPServer::~CTCPServer() { StopServer(); #ifndef NOCLOUD if (m_pProxyServer != NULL) { m_pProxyServer->stop(); delete m_pProxyServer; m_pProxyServer = NULL; } #endif }
void App::Exit() { if (testing) { char* testmsg = "This is a test message :-)"; LoginPanel->Message(testmsg); sleep(3); } else { delete LoginPanel; StopServer(); RemoveLock(); } exit(OK_EXIT); }
void RemoteDebuggerProxy::Shutdown() { if ( mSessionGuid != GUID_NULL ) { // When you close the client interface to the remote agent (Cmd), the agent closes its // client interface to the debug engine (Event). To allow that call back, stop the client // before stopping the server. StopClient( mhContext ); StopServer(); } }
void CMMServer::Init(){ if (thePrefs.IsMMServerEnabled() && !m_pSocket){ m_pSocket = new CListenMMSocket(this); if (!m_pSocket->Create()){ StopServer(); AddLogLine(false, GetResString(IDS_MMFAILED) ); } else{ AddLogLine(false, GetResString(IDS_MMSTARTED), thePrefs.GetMMPort(), _T(MM_STRVERSION)); } } }
MuHttpServer::~MuHttpServer() { if (mServerIsRunning) { StopServer(); } // Destroy registrations here before the EHS class destructor is called for (QMap<QString, EHS*>::iterator it = mRegistrations.begin(); it != mRegistrations.end(); ++it) { delete it.value(); } }
windowserveur::windowserveur(QWidget *parent) : QDialog(parent), ui(new Ui::windowserveur) { server = new BmNetworkTCPServer(); ui->setupUi(this); connect(ui->btStartServer,SIGNAL(clicked()),this, SLOT(StartServer())); connect(ui->btStopServer,SIGNAL(clicked()),this, SLOT(StopServer())); connect(ui->btQuitterServer,SIGNAL(clicked()),this,SLOT(QuitServer())); }
bool CAirPlayServer::StartServer(int port, bool nonlocal) { StopServer(true); ServerInstance = new CAirPlayServer(port, nonlocal); if (ServerInstance->Initialize()) { ServerInstance->Create(); return true; } else return false; }
void App::Halt() { // Stop alarm clock alarm(0); // Write message LoginPanel->Message((char*)cfg.getOption("shutdown_msg").c_str()); sleep(3); // Stop server and halt StopServer(); RemoveLock(); system(cfg.getOption("halt_cmd").c_str()); exit(OK_EXIT); }
bool KristalliProtocolModule::StartServer(unsigned short port, SocketTransportLayer transport) { StopServer(); const bool allowAddressReuse = true; server = network.StartServer(port, transport, this, allowAddressReuse); if (!server) { LogError("Failed to start server on port " + ToString((int)port)); throw Exception(("Failed to start server on port " + ToString((int)port) + ". Please make sure that the port is free and not used by another application. The program will now abort.").c_str()); } LogInfo("Started server on port " + ToString((int)port)); return true; }
void CGameServDlg::UpdateServerMgr(DWORD timeDelta) { // Sanity checks... if (!m_pServerMgr) return; if (!IsRunning()) return; // Let the server update... if (m_pServerMgr->Update(0) != DTRUE) { WriteServerError(); StopServer(); } }
void cRoot::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output) { // Some commands are built-in: if (a_Cmd == "stop") { StopServer(); return; } else if (a_Cmd == "restart") { m_StopEvent.Set(); m_InputThreadRunFlag.clear(); return; } LOG("Executing console command: \"%s\"", a_Cmd.c_str()); m_Server->ExecuteConsoleCommand(a_Cmd, a_Output); }
bool CTCPServer::StartServer(const std::string &address, const std::string &port) { try { StopServer(); if (m_pTCPServer!=NULL) delete m_pTCPServer; m_pTCPServer=new CTCPServerInt(address,port,this); } catch(std::exception& e) { _log.Log(LOG_ERROR,"Exception: %s",e.what()); return false; } //Start worker thread m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CTCPServer::Do_Work, this))); return (m_thread!=NULL); }
/******************************************************************** * Certain signals must be handled by this process. These * include those that indicate the child has gone down. *******************************************************************/ static void SignalAbort(int nSignal) { Feedback fb(sSlaveId + " signal handler"); if (nSignal == SIGPIPE) { fb.Warning("Received SIGPIPE signal on host ") << Hostname() << ". This probably means the slave process has died. The slave server on this host will now stop. " << "You may have to log in to the host and kill the processes manually. Slave server pid is " << getpid() << ", child (slave) pid is " << child_pid << "."; StopServer(); } else if (nSignal != SIGSTOP) { fb.Warning("Caught signal ") << nSignal << ". Exiting."; exit(nSignal); } }
int KsCardDaemonSvr::StartServer(int port) { if(NULL != server_) { wxLogMessage(wxT("服务已启动")); return 0; } wxIPV4address addr; addr.Service(port); addr.LocalHost(); server_ = new wxSocketServer(addr,wxSOCKET_REUSEADDR); if(!server_->IsOk()) { wxLogError(wxT("启动服务失败")); StopServer(); return -1; } server_->SetTimeout(30); // 30 seconds return 0; }
int main(int argc, char *argv[]) { std::vector<std::thread*> workerThreads; std::thread acceptThread; gClientInfoSet = new LFList(); gClientInfo_DelList = new LFNode(MIN_INT); gClientInfoSet->Initialize(); InitializeServer(); InitializeMonster(); acceptThread = std::thread(AcceptThreadFunc); for (int i = 0; i < NUM_THREADS; ++i) workerThreads.push_back(new std::thread(WorkerThreadFunc)); while (!gShutdown) Sleep(1000); // 다음과 같이 Main Thread를 1초마다 잠들게 하여 // Processor가 Main Thread를 점유하는 일을 최대한 저해하도록 한다. acceptThread.join(); for (auto t : workerThreads) { t->join(); delete t; } StopServer(); gClientInfoSet->Rearrangement(); while (0 != gClientInfo_DelList->next) { LFNode *temp = gClientInfo_DelList; gClientInfo_DelList = gClientInfo_DelList->GetNext(); delete temp; } delete gClientInfo_DelList; delete gClientInfoSet; return 0; }
//--------------------------------------------------------------------------- void __fastcall TFtpServerForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; int Minim; try { StopServer(); Minim = StartMinimizedCheckBox->Checked; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); IniFile->WriteInteger(SectionWindow, KeyMinim, Minim); IniFile->WriteString(SectionData, KeyPort, FPort); IniFile->Free(); } __except (TRUE) { // Ignore any exception when we are closing } }
HRESULT RemoteDebuggerProxy::Start() { if ( mSessionGuid != GUID_NULL ) return S_OK; HRESULT hr = S_OK; GUID sessionGuid = { 0 }; wchar_t sessionGuidStr[GUID_LENGTH + 1] = L""; int ret = 0; hr = CoCreateGuid( &sessionGuid ); if ( FAILED( hr ) ) return hr; ret = StringFromGUID2( sessionGuid, sessionGuidStr, _countof( sessionGuidStr ) ); _ASSERT( ret > 0 ); if ( ret == 0 ) return E_FAIL; mSessionGuid = sessionGuid; hr = StartAgent( sessionGuidStr ); if ( FAILED( hr ) ) return hr; hr = StartServer( sessionGuidStr ); if ( FAILED( hr ) ) return hr; SetRemoteEventCallback( this ); hr = StartClient( sessionGuidStr, sessionGuid, mhContext ); SetRemoteEventCallback( NULL ); if ( FAILED( hr ) ) { StopServer(); return hr; } return S_OK; }
//}} //************************************************************************ int APIENTRY WinMain(HINSTANCE a_hInstance, HINSTANCE, LPSTR a_pszCmd, int a_nCount) { Util::TCommandLineInfo cmdLine(a_pszCmd); switch(cmdLine.m_eCommand) { case Util::TCommandLineInfo::eDebug: return RunAsApplication(a_hInstance); case Util::TCommandLineInfo::eInstall: return Service::Install() ? 0 : -1; case Util::TCommandLineInfo::eUnInstall: return Service::UnInstall() ? 0 : -1; case Util::TCommandLineInfo::eStart: { if(Service::Run()) return 0; if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) return RunAsApplication(a_hInstance); } case Util::TCommandLineInfo::eStop: return StopServer(); } char buffer[256] = {0}; DWORD length = 0; GetUserObjectInformation(GetProcessWindowStation(), UOI_NAME, buffer, 256, &length); if (stricmp(buffer, "WinSta0") == 0) { MessageBox(NULL, "No argument", "Error", MB_ICONSTOP); } return 0; }
bool CTCPServer::StartServer(const std::string &address, const std::string &port) { int tries = 0; bool exception = false; std::string listen_address = address; do { try { exception = false; StopServer(); if (m_pTCPServer != NULL) { _log.Log(LOG_ERROR, "Stopping TCPServer should delete resources !"); } m_pTCPServer = new CTCPServerInt(listen_address, port, this); } catch (std::exception& e) { exception = true; switch (tries) { case 0: listen_address = "::"; break; case 1: listen_address = "0.0.0.0"; break; case 2: _log.Log(LOG_ERROR, "Exception starting shared server: %s", e.what()); return false; } tries++; } } while (exception); _log.Log(LOG_NORM, "Starting shared server on: %s:%s", listen_address.c_str(), port.c_str()); //Start worker thread m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CTCPServer::Do_Work, this))); return (m_thread!=NULL); }