//-------------------------------------------------------------- // Stops the client thread. //-------------------------------------------------------------- void ofxTCPSyncClient::quit() { out("Quitting."); if(bTCP){ sendDisconnect(); } else{ sendDisconnect(); } }
void Connection::close() { if (state == HANDSHAKING || state == CONNECTED) { state = CLOSED; sendDisconnect(); } }
void DefaultOperationTcpChannel::closeConnection() { KAA_MUTEX_LOCKING("channelGuard_"); KAA_MUTEX_UNIQUE_DECLARE(lock, channelGuard_); KAA_MUTEX_LOCKED("channelGuard_"); bool wasConnected = isConnected_; KAA_LOG_TRACE(boost::format("Channel [%1%] closing connection: isConnected '%2%'") % getId() % boost::io::group(std::boolalpha, wasConnected)); isFirstResponseReceived_ = false; isConnected_ = false; isPendingSyncRequest_ = false; KAA_MUTEX_UNLOCKING("channelGuard_"); KAA_UNLOCK(lock); KAA_MUTEX_UNLOCKED("channelGuard_"); if (wasConnected) { pingTimer_.cancel(); connAckTimer_.cancel(); sendDisconnect(); boost::system::error_code errorCode; sock_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, errorCode); sock_->close(errorCode); responseProcessor.flush(); } }
/* * Safely close a socket. The following note comes from socket_md.c * which is in src/win32/hpi/src/ in the JDK sources. * * Generally speaking, it is important to shutdown a socket before * closing it, since failing to do so can sometimes result in a TCP * RST (abortive close) which is disturbing to the peer of the * connection. * * The Winsock way to shutdown a socket is the Berkeley call * shutdown(). We do not want to call it on Win95, since it * sporadically leads to an OS crash in IFS_MGR.VXD. Complete hull * breach. Blue screen. Ugly. * * So we use the WSASendDisconnect function if it was found at initialization * time, before calling closesocket. */ void sysCloseSocket(SOCKET s) { sysInitSocketLibrary(); if (s <= 0) { return; } if (sendDisconnect) { sendDisconnect(s, NULL); /* WSASendDisconnect */ } closesocket(s); }
//Parse void ServerClient::parseConnect(Packet &packet) { const std::string &name = packet.getString(); if(g_game->getState() == GameState::Running) { sendDisconnect(ErrorType::GameRunning); return; } if(g_game->getState() == GameState::Starting) { sendDisconnect(ErrorType::GameStarting); return; } if(g_game->getCreatures().size() >= 4) { sendDisconnect(ErrorType::GameFull); return; } if(g_game->getCreatureByName(name)) { sendDisconnect(ErrorType::NameUsed); return; } m_creature = new Creature(); m_creature->setServerClient(this); m_creature->setName(name); g_game->sendChatMessage(0, name + " has joined the room."); g_game->addCreature(m_creature); sendLoginResponse(); for(auto it : g_game->getCreatures()) g_game->sendCreature(it->getId(), it->getName()); }
void NetworkConnection::closeConnection(bool send_disconnect) { if(!qsocket) //when can this happen? this function shouldn't be //called if we get here!!! return; /* FIXME We also need to close any open dispatches, * boards etc., for instance if there was an error. * Clearing lists and such would be good to. * there's a MainWindow::connexionClosed that does * good stuff we should move into somewhere * nearby., also what about onError?*/ if(connectingDialog) { connectingDialog->deleteLater(); connectingDialog = 0; } if(qsocket->state() != QTcpSocket::UnconnectedState) { if(send_disconnect) { if(console_dispatch) console_dispatch->recvText("Disconnecting...\n"); qDebug("Disconnecting..."); sendDisconnect(); //legit? } // Close it. qsocket->close(); // Closing succeeded, return message if (qsocket->state() == QTcpSocket::UnconnectedState) { //authState = LOGIN; //sendTextToApp("Connection closed.\n"); } } // Not yet closed? Data will be written and then slot OnDelayClosedFinish() called //delete qsocket; qsocket->deleteLater(); //for safety qsocket = 0; onClose(); return; }
ImProxy::~ImProxy() { mShell->ImExited(); if (!mConnected) return; if (FbShellManager::instance()->activeShell() == mShell) { TtyInput::instance()->setRawMode(false); } sendDisconnect(); setFd(-1); extern void waitChildProcessExit(s32 pid); waitChildProcessExit(mPid); Rectangle rect = { 0, 0, 0, 0 }; for (u32 i = 0; i < NR_IM_WINS; i++) { if (mWins[i].w) setImWin(i, rect); } }
//-------------------------------------------------------------- void ofxMatrixNetworkServer::update() { //for each client lets send them a message letting them know what port they are connected on for(int i = 0; i < getLastID(); i++){ if(isClientConnected(i)){ //if we don't have a string allocated yet: lets create one //if(i >= storeText.size() ){ // storeText.push_back( string() ); //} //if we don't have a string allocated yet: lets create one if(i >= tx_valid.size() ){ tx_valid.push_back(0); } //we only want to update the text we have recieved there is data string str = receive(i); if(str == "handshake"){ ofLog(OF_LOG_NOTICE, "handshake with client " + ofToString(i)); sendHandshake(i); tx_valid[i] = 1; }else if(str.find_first_of("nextframe") != -1){ //ofLog(OF_LOG_NOTICE, "nextframe for client " + ofToString(i) + " - " + str); tx_valid[i] = 2; }else if(str == "disconnect"){ ofLog(OF_LOG_NOTICE, "disconnect client " + ofToString(i)); sendDisconnect(i); disconnectClient(i); tx_valid[i] = 0; } //if(str.length() > 0){ // storeText[i] = str; //} }else{ tx_valid[i] = 0; } } }
static void sendDisconnectWrapper(void) { if(global_client_config) sendDisconnect(0, global_client_config); }
void QMQTT::ClientPrivate::disconnectFromHost() { sendDisconnect(); _network->disconnectFromHost(); }
void ClientPrivate::disconnect() { sendDisconnect(); network->disconnect(); }