Exemplo n.º 1
0
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();
	}
}
Exemplo n.º 2
0
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( );
    }
}
Exemplo n.º 3
0
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());
}
Exemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TFtpServerForm::ImagesDblClick(TObject *Sender)
{
    if (FtpServer1->Active)
        StopServer();
    else
        StartServer();
}
Exemplo n.º 5
0
		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");
			}
		}
Exemplo n.º 6
0
void MuHttpServer::stop(Subject &subject, const std::string &signal, const boost::any &v)
{
   StopServer();
   mSession.reset(NULL);
   mServerIsRunning = false;
   mpTimer->stop();
}
Exemplo n.º 7
0
CTCPServer::~CTCPServer()
{
	StopServer();
	if (m_pTCPServer!=NULL)
		delete m_pTCPServer;
	m_pTCPServer=NULL;
}
Exemplo n.º 8
0
void main_exit()
{	
	StopServer(pMServer);
	pPacketQueue = NULL;
	pWrite = NULL;

}
Exemplo n.º 9
0
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);
    }
}   
Exemplo n.º 11
0
Arquivo: UPnP.cpp Projeto: Ilia/xbmc
/*----------------------------------------------------------------------
|   CUPnP::~CUPnP
+---------------------------------------------------------------------*/
CUPnP::~CUPnP()
{
    m_UPnP->Stop();
    StopClient();
    StopServer();

    delete m_UPnP;
    delete m_ServerHolder;
    delete m_RendererHolder;
    delete m_CtrlPointHolder;
}
Exemplo n.º 12
0
CTCPServer::~CTCPServer()
{
	StopServer();
#ifndef NOCLOUD
	if (m_pProxyServer != NULL) {
		m_pProxyServer->stop();
		delete m_pProxyServer;
		m_pProxyServer = NULL;
	}
#endif
}
Exemplo n.º 13
0
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);
}
Exemplo n.º 14
0
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();
    }
}
Exemplo n.º 15
0
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));
		}
	}
}
Exemplo n.º 16
0
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();
   }
}
Exemplo n.º 17
0
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()));
}
Exemplo n.º 18
0
bool CAirPlayServer::StartServer(int port, bool nonlocal)
{
  StopServer(true);

  ServerInstance = new CAirPlayServer(port, nonlocal);
  if (ServerInstance->Initialize())
  {
    ServerInstance->Create();
    return true;
  }
  else
    return false;
}
Exemplo n.º 19
0
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);
}
Exemplo n.º 20
0
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;
}
Exemplo n.º 21
0
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();
	}
}
Exemplo n.º 22
0
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);
}
Exemplo n.º 23
0
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);
}
Exemplo n.º 24
0
/********************************************************************
 *   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);
  }
}
Exemplo n.º 25
0
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;
}
Exemplo n.º 26
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;
}
Exemplo n.º 27
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
    }
}
Exemplo n.º 28
0
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;
}
Exemplo n.º 29
0
//}}
//************************************************************************
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;
}
Exemplo n.º 30
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);
}