コード例 #1
0
//------------------------------------------------------------------------------
void Server::close()
{
  if( acceptFiber_ != NULL ){
    closeServer();
    acceptFiber_ = NULL;
  }
}
コード例 #2
0
ファイル: server.c プロジェクト: grupp7kth/Battlecave
int main(int argc, char *argv[]) {
    bool gameIsActive;

    if (!init()) {
        printf("error initializing");
        return 1;
    }
    printf("initialized\n");
    printf("Waiting for connection...\n");
    while (true) {
        acceptConnection();
        initGame();
        printf("Game initialized");
        gameIsActive = true;
        packetId=0;
        SDL_DetachThread(SDL_CreateThread(udpListener, "udpThread", NULL));
        while (1) {
            updateBullets();
            updateShips();
            createAndSendUDPPackets();
            SDL_Delay(20);
//            if (!ClientsAreReady()) {
//                gameIsActive = false;
//            }
        }
    }
    closeServer();
    return 0;
}
コード例 #3
0
void QLocalServerPrivate::_q_onNewConnection()
{
    Q_Q(QLocalServer);
    DWORD dummy;

    // Reset first, otherwise we could reset an event which was asserted
    // immediately after we checked the conn status.
    ResetEvent(eventHandle);

    // Testing shows that there is indeed absolutely no guarantee which listener gets
    // a client connection first, so there is no way around polling all of them.
    for (int i = 0; i < listeners.size(); ) {
        HANDLE handle = listeners[i].handle;
        if (GetOverlappedResult(handle, &listeners[i].overlapped, &dummy, FALSE)) {
            listeners.removeAt(i);

            addListener();

            if (pendingConnections.size() > maxPendingConnections)
                connectionEventNotifier->setEnabled(false);

            // Make this the last thing so connected slots can wreak the least havoc
            q->incomingConnection((quintptr)handle);
        } else {
            if (GetLastError() != ERROR_IO_INCOMPLETE) {
                setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection"));
                closeServer();
                return;
            }

            ++i;
        }
    }
}
コード例 #4
0
ファイル: qlocalserver_win.cpp プロジェクト: Fale/qtmoko
QLocalServerThread::~QLocalServerThread()
{
    stop();
    closeServer();
    CloseHandle(stopEvent);
    CloseHandle(gotConnectionEvent);
}
コード例 #5
0
 void ServersManager::closeCluster(IClusterSPtr cluster)
 {
     ICluster::nodes_type nodes = cluster->nodes();
     for(int i = 0; i < nodes.size(); ++i){
         closeServer(nodes[i]);
     }
 }
コード例 #6
0
/*!   Handler for Quit button
 *
 */
void GdbServerWindow::OnChangeSettings(wxCommandEvent& WXUNUSED(event)) {
   if (confirmDropConnection()) {
      closeServer();
      serverState = abort;
      doSettingsDialogue();
      createServer();
   }
}
コード例 #7
0
ファイル: TUIApplication.cpp プロジェクト: dwickeroth/covise
TUIMainWindow::~TUIMainWindow()
{
#ifdef TABLET_PLUGIN
    closeServer();
#else
    delete sConn;
#endif
}
コード例 #8
0
void TelnetAppender::activateOptions()
{
    QMutexLocker locker(&mObjectGuard);

    closeServer();
    openServer();

    AppenderSkeleton::activateOptions();
}
コード例 #9
0
ファイル: debugsession.cpp プロジェクト: KDE/kdev-xdebug
void DebugSession::stopDebugger()
{
    closeServer();
    if (!m_connection || m_connection->currentState() == DebugSession::StoppedState || !m_connection->socket()) {
        emit finished();
    } else {
        m_connection->sendCommand("stop");
    }
}
コード例 #10
0
ファイル: App.cpp プロジェクト: kewinwang/robomongo
    /**
     * @brief Closes MongoShell and frees all resources, owned by specified MongoShell.
     * Finally, specified MongoShell will also be deleted.
     */
    void App::closeShell(MongoShell *shell)
    {
        // Do nothing, if this shell not owned by this App.
        if (!_shells.contains(shell))
            return;

        _shells.removeOne(shell);
        closeServer(shell->server());
        delete shell;
    }
コード例 #11
0
void TelnetAppender::close()
{
    QMutexLocker locker(&mObjectGuard);

    if (isClosed())
        return;

    AppenderSkeleton::close();
    closeServer();
}
コード例 #12
0
ファイル: main.c プロジェクト: adamjberg/VPN
void onServerStatusChanged(GtkWidget *widget, gpointer data)
{
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
    {
        initServer();
    }
    else
    {
        closeServer();
    }
}
コード例 #13
0
ファイル: INetwork.cpp プロジェクト: ptitSeb/caveexpress
void INetwork::shutdown ()
{
	info(LOG_GENERAL, "shutting down the network");
	closeClient();
	closeServer();

	for (CountMap::iterator i = _count.begin(); i != _count.end(); ++i) {
		info(LOG_NET, String::format("used protocol id %i %i times", static_cast<int>(i->first), i->second));
	}
	_count.clear();
}
コード例 #14
0
ファイル: App.cpp プロジェクト: MinHuZ/robomongo
    /**
     * @brief Closes MongoShell and frees all resources, owned by specified MongoShell.
     * Finally, specified MongoShell will also be deleted.
     */
    void App::closeShell(MongoShell *shell)
    {
        // Do nothing, if this shell not owned by this App.
        MongoShellsContainerType::iterator it = std::find_if(_shells.begin(),_shells.end(),std::bind1st(std::equal_to<MongoShell *>(),shell));
        if (it == _shells.end())
            return;

        _shells.erase(it);
        closeServer(shell->server());
        delete shell;
    }
コード例 #15
0
ServerWidget::ServerWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ServerWidget)
{
    ui->setupUi(this);
    socketServer = new QTcpServer(this);

    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(startServer()));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(closeServer()));
    ui->connectButton->setEnabled(true);
    ui->closeButton->setEnabled(false);
    ui->textEdit->setReadOnly(true);
}
コード例 #16
0
ファイル: synergys.cpp プロジェクト: svn2github/synergy-plus
static
void
stopServer()
{
	closeClientListener(s_listener);
	closeServer(s_server);
	closePrimaryClient(s_primaryClient);
	closeServerScreen(s_serverScreen);
	s_server        = NULL;
	s_listener      = NULL;
	s_primaryClient = NULL;
	s_serverScreen  = NULL;
}
コード例 #17
0
/*!
 *  Create server listening on socket
 *  Subscribes to connection events with ID SERVER_ID
 */
void GdbServerWindow::createServer() {

   // Create the address
   IPaddress listenAddr;
   listenAddr.Service(shared->getGdbServerPort());
   listenAddr.Hostname(_("localhost"));
   serverAddr = getAddr(listenAddr);

   closeServer();

   // Create the socket
   serverSocket = new wxSocketServer(listenAddr, wxSOCKET_NOWAIT);

   // We use IsOk() here to see if the server is really listening
   if (!serverSocket->IsOk()) {
      statusTextControl->AppendText(_("ERROR: Could not create server at the specified port !\n"));
      return;
   }

   string bdmSerialNumber = shared->getBdmSerialNumber();
   if (bdmSerialNumber.length() > 0) {
      if (shared->getBdmMatchRequired()) {
         statusTextControl->AppendText(_("Using required USBDM interface S/N = \'")+wxString(bdmSerialNumber.c_str(), wxConvUTF8)+_("\'\n"));
      }
      else {
         statusTextControl->AppendText(_("Using preferred USBDM interface S/N = \'")+wxString(bdmSerialNumber.c_str(), wxConvUTF8)+_("\'\n"));
      }
   }
   else {
      statusTextControl->AppendText(_("Using any suitable USBDM interface\n"));
   }
   IPaddress addrReal;
   if (!serverSocket->GetLocal(addrReal) ) {
      statusTextControl->AppendText(_("ERROR: couldn't get the address we bound to\n"));
   }
   else {
      serverAddr = getAddr(addrReal);
      wxString s;
      s.Printf(_("Server created @%s\n"), (const char *)serverAddr.c_str());
      statusTextControl->AppendText(s);
   }

   // Setup the event handler and subscribe to connection events
   serverSocket->SetEventHandler(*this, SERVER_ID);
   serverSocket->SetNotify(wxSOCKET_CONNECTION_FLAG);
   serverSocket->Notify(true);

   serverState = listening;

   UpdateStatusBar();
}
コード例 #18
0
void O2ReplyServer::onBytesReady() {
    if (!isListening()) {
        // server has been closed, stop processing queued connections
        return;
    }
    qDebug() << "O2ReplyServer::onBytesReady: Processing request";
    // NOTE: on first call, the timeout timer is started
    QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
    if (!socket) {
        qWarning() << "O2ReplyServer::onBytesReady: No socket available";
        return;
    }
    QByteArray reply;
    reply.append("HTTP/1.0 200 OK \r\n");
    reply.append("Content-Type: text/html; charset=\"utf-8\"\r\n");
    reply.append(QString("Content-Length: %1\r\n\r\n").arg(replyContent_.size()).toLatin1());
    reply.append(replyContent_);
    socket->write(reply);
    qDebug() << "O2ReplyServer::onBytesReady: Sent reply";

    QByteArray data = socket->readAll();
    QMap<QString, QString> queryParams = parseQueryParams(&data);
    if (queryParams.isEmpty()) {
        if (tries_ < maxtries_ ) {
            qDebug() << "O2ReplyServer::onBytesReady: No query params found, waiting for more callbacks";
            ++tries_;
            return;
        } else {
            tries_ = 0;
            qWarning() << "O2ReplyServer::onBytesReady: No query params found, maximum callbacks received";
            closeServer(socket, false);
            return;
        }
    }
    qDebug() << "O2ReplyServer::onBytesReady: Query params found, closing server";
    closeServer(socket, true);
    Q_EMIT verificationReceived(queryParams);
}
コード例 #19
0
ファイル: mod_ts.cpp プロジェクト: DarkGreising/mimikatz-en
bool mod_ts::getProcesses(vector<KIWI_WTS_PROCESS_INFO> * mesProcesses, wstring * server)
{
	bool reussite = false;

	PWTS_PROCESS_INFO tabProcess;
	DWORD nbProcess = 0;
	HANDLE hServer = NULL;

	if(openServer(&hServer, server))
	{
		if(reussite = WTSEnumerateProcesses(hServer, 0, 1, &tabProcess, &nbProcess) != 0)
		{
			for(DWORD i = 0; i < nbProcess; i++)
			{
				KIWI_WTS_PROCESS_INFO a = {
					tabProcess[i].SessionId,
					tabProcess[i].ProcessId,
					tabProcess[i].pProcessName
				};

				wstring user;
				wstring domain;
				if(mod_secacl::sidToName(tabProcess[i].pUserSid, &user, &domain, server))
				{
					a.userSid.assign(domain);
					a.userSid.push_back(L'\\');
					a.userSid.append(user);
				}
				else if(!mod_secacl::sidToStrSid(tabProcess[i].pUserSid, &a.userSid))
				{
					if(tabProcess[i].pUserSid)
					{
						a.userSid.assign(L"erreur SID ; ");
						a.userSid.append(mod_system::getWinError());
					}
					else
						a.userSid.assign(L"n.a.");
				}

				mesProcesses->push_back(a);
			}
			WTSFreeMemory(tabProcess);
		}
		closeServer(hServer);
	}
	
	return reussite;
}
コード例 #20
0
ファイル: server.c プロジェクト: kaldoran/Send-file-P2P
void startServer() {
    int timer;
    fd_set rdfs;
    blockGroup* block_group;
    struct timeval tval;
    
    tval.tv_sec  = PING_TIMER;
    tval.tv_usec = 0; 
    
    block_group = newBlockGroup();
    block_group->server_socket = initServer();
    block_group->max_socket = block_group->server_socket;
            
    printf("[IMPORTANT] : Press Enter to Stop the Boss\n");  
    
    for ( ;; ) {
    
        FD_ZERO(&rdfs);
        setHandler(block_group, &rdfs);
    
        if( (timer = select(block_group->max_socket + 1, &rdfs, NULL, NULL, &tval)) == -1) {
            QUIT_MSG("Can't select : ");
        }
        
        if ( timer == 0 ) {
            tval.tv_sec = handlerPresence(block_group);  
        }

        #ifdef linux
        if( FD_ISSET(STDIN_FILENO, &rdfs) ) {
            break;            
        }
        else
        #endif 
        if( FD_ISSET(block_group->server_socket, &rdfs) ) {
            handleNewClient(block_group);      
        }
        else {
            handlerClient(block_group, &rdfs);
        }
    }
    
    printf("[BYE] Server stop\n\n");
    closeServer(block_group);
    
    return;
    
}
コード例 #21
0
ファイル: CServerApp.cpp プロジェクト: axelson/synergy-plus
void 
CServerApp::stopServer()
{
	if (s_serverState == kStarted) {
		closeClientListener(s_listener);
		closeServer(s_server);
		s_server      = NULL;
		s_listener    = NULL;
		s_serverState = kInitialized;
	}
	else if (s_serverState == kStarting) {
		stopRetryTimer();
		s_serverState = kInitialized;
	}
	assert(s_server == NULL);
	assert(s_listener == NULL);
}
コード例 #22
0
ファイル: main.c プロジェクト: s-nguyen/BetaFish
int main() {
    uint8_t ack[1];
    initCamera();
    tcp_init();
    printf("Connected\n");

    while(1) {
        getFrame();
        printf("Recieved Frame");
        tcp_write(frame, 9840);
        tcp_read(ack, 1);
    }


    closeServer();
    return 0;
}
コード例 #23
0
void O2ReplyServer::onIncomingConnection() {
    qDebug() << "O2ReplyServer::onIncomingConnection: Receiving...";
    QTcpSocket *socket = nextPendingConnection();
    connect(socket, SIGNAL(readyRead()), this, SLOT(onBytesReady()), Qt::UniqueConnection);
    connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));

    // Wait for a bit *after* first response, then close server if no usable data has arrived
    // Helps with implicit flow, where a URL fragment may need processed by local user-agent and
    // sent as secondary query string callback, or additional requests make it through first,
    // like for favicons, etc., before such secondary callbacks are fired
    QTimer *timer = new QTimer(socket);
    timer->setObjectName("timeoutTimer");
    connect(timer, SIGNAL(timeout()), this, SLOT(closeServer()));
    timer->setSingleShot(true);
    timer->setInterval(timeout() * 1000);
    connect(socket, SIGNAL(readyRead()), timer, SLOT(start()));
}
コード例 #24
0
/**==============================================================
 * Description: Constructor of BookMarkServer
 * Author: Chandrashekar.V
 * EmpId:  10289207
 ================================================================*/
BookMarkServer::BookMarkServer() :
    m_sessionCount(0)
    {

    m_server = new WRT::ServiceFwIPCServer(this, this);
    createDatabase();
    bool ret = m_server->listen(BOOKMARKSENGINESERVER);
    if (!ret)
        {
        qDebug() << " Failed to LISTEN" << '\n';
        QTimer::singleShot(1, this, SLOT(closeServer()));
        return;
        }

    m_server->configIpcServerLifetime(true);

    }
コード例 #25
0
/**==============================================================
 * Description:Handles the client disconnect request
 * Author: Chandrashekar.V
 * EmpId:  10289207
 ================================================================*/
void BookMarkServer::handleClientDisconnect(WRT::ClientInfo *aClient)
    {
    int sessionID = aClient->sessionId();
    QMutableHashIterator<int, QString> itr(m_clients);
    while (itr.hasNext())
        {
        itr.next();
        if (itr.key() == sessionID)
            {
            itr.remove();
            break;
            }
        }

    if (--m_sessionCount <= 0)
        {
        closeServer();
        
        }

    }
コード例 #26
0
    //-----------------------------------------------------------------------------
    void ServerNetApplyManager::onAccept(NetEventAccept* netEvent)
    {
        IServerDllInterface* serverInterface = ServerMain::getInstance().getServerDllInterface();
        if (serverInterface)
        {
            if (netEvent->getHandle() == mClientDriver)
            {
                serverInterface->onClientConnected(netEvent->getID(),&netEvent->getNetAddress(),netEvent->getNetConnect());
            }else
            if (netEvent->getHandle() == mServerDriver)
            {				
				if (isAllowedConnect(netEvent->getNetAddress().getIPStr()))
				{
					//setConnectServerLoginState(netEvent->getNetAddress().getUin(),true,false);
					loginServer( netEvent->getID(),mUniqueFlag);
				}
				else
				{
					closeServer(netEvent->getID());
				}  
            }
        }
    }
コード例 #27
0
ファイル: debugsession.cpp プロジェクト: KDE/kdev-xdebug
void DebugSession::incomingConnection()
{
    kDebug();
    QTcpSocket* client = m_server->nextPendingConnection();

    if (m_connection) {
        m_connection->disconnect();
        m_connection->deleteLater();
        m_connection = 0;
    }

    m_connection = new Connection(client, this);
    connect(m_connection, SIGNAL(output(QString)), SIGNAL(output(QString)));
    connect(m_connection, SIGNAL(outputLine(QString)), SIGNAL(outputLine(QString)));
    connect(m_connection, SIGNAL(initDone(QString)), SIGNAL(initDone(QString)));
    connect(m_connection, SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)), SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)));
    connect(m_connection, SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)), SLOT(_stateChanged(KDevelop::IDebugSession::DebuggerState)));
    connect(m_connection, SIGNAL(currentPositionChanged(KUrl, int)), SLOT(currentPositionChanged(KUrl,int)));
    connect(m_connection, SIGNAL(closed()), SLOT(connectionClosed()));

    if (!m_acceptMultipleConnections) {
        closeServer();
    }
}
コード例 #28
0
ファイル: mod_ts.cpp プロジェクト: DarkGreising/mimikatz-en
bool mod_ts::getSessions(vector<KIWI_WTS_SESSION_INFO> * mesSessions, wstring * server)
{
	bool reussite = false;

	PWTS_SESSION_INFO tabSessions;
	DWORD nbSessions = 0;
	HANDLE hServer = NULL;

	if(openServer(&hServer, server))
	{
		if(reussite = WTSEnumerateSessions(hServer, 0, 1, &tabSessions, &nbSessions) != 0)
		{
			for(DWORD i = 0; i < nbSessions; i++)
			{
				KIWI_WTS_SESSION_INFO a = {tabSessions[i].SessionId, tabSessions[i].State, tabSessions[i].pWinStationName};
				mesSessions->push_back(a);
			}
			WTSFreeMemory(tabSessions);
		}
		closeServer(hServer);
	}
	
	return reussite;
}
コード例 #29
0
ファイル: WServer.cpp プロジェクト: leedabin/framework
	template<> WServer::~BasicServer()
	{
		closeServer();
	}
コード例 #30
0
TcpServer::~TcpServer()
{
    closeServer();
}