int getServer(int port, const char * addr,int timeout) { if (sock_>=0) close(sock_); sock_=socket(PF_INET, SOCK_DGRAM, 0); if (sock_<0) return sock_; struct hostent *phe; address_.sin_family=AF_INET; address_.sin_port=htons(port); if ( phe=gethostbyname(addr) ) memcpy((char *)&address_.sin_addr, phe->h_addr, phe->h_length); else if ( (address_.sin_addr.s_addr = inet_addr(addr)) == INADDR_NONE ) { close(sock_); errno=EADDRNOTAVAIL; return -2; } if (pingServer(timeout)<0) { return -3; } return sock_; }
void help_about_server (void) { char *buildId; char *serverName; char *adminEmailAddr; pingServer (); }
void *AgentPingThread(void *arg) { while (1) { pingServer("10.204.244.243"); sleep(10); } return 0; }
Session::Session(QObject *parent) : IrcSession(parent), m_currentLag(-1), m_maxLag(120000), m_quit(false) { connect(this, SIGNAL(connected()), this, SLOT(onConnected())); connect(this, SIGNAL(password(QString*)), this, SLOT(onPassword(QString*))); connect(this, SIGNAL(capabilities(QStringList,QStringList*)), this, SLOT(onCapabilities(QStringList,QStringList*))); connect(this, SIGNAL(messageReceived(IrcMessage*)), SLOT(handleMessage(IrcMessage*))); setAutoReconnectDelay(15); connect(&m_reconnectTimer, SIGNAL(timeout()), this, SLOT(open())); connect(&m_pingTimer, SIGNAL(timeout()), this, SLOT(pingServer())); connect(this, SIGNAL(connectedChanged(bool)), SLOT(togglePingTimer(bool))); }
void MumbleClient::setupEncryption(quint8 *message, quint64 size) { MumbleProto::CryptSetup crypt; crypt.ParseFromArray(message,size); _key = crypt.key(); _client_nonce = crypt.client_nonce(); _server_nonce = crypt.server_nonce(); #ifndef NO_CRYPT _crypt_state->setKey(reinterpret_cast<const unsigned char*>(_key.c_str()), reinterpret_cast<const unsigned char*>(_client_nonce.c_str()), reinterpret_cast<const unsigned char*>(_server_nonce.c_str())); #endif _encryption_set = true; qDebug() << "Encryption setup ok "; pingServer(); }
//外网模式下,服务器在线测试 USER_FUNC void pingTest(void *arg) { while (getPingServerThreadFlag()) { sleep(5); pingServer(); sleep(120); u_printf("check ping result"); if (getPingResultFlag()) { //if ping result is correct setPingResultFlag(0); } else { //若ping服务器无反应,则释放资源并让主板重新上线 resetPingData(); //关闭socket连接 closeSocket(getSocketFd()); sleep(10); //10s后主板开始重新上线 initPingData(); connectServer(); loginServer(); if (hfthread_create(recvTest, "RECV_THREAD", 256, NULL,HFTHREAD_PRIORITIES_LOW, NULL, NULL) != HF_SUCCESS) { u_printf("create recvMessage thread fail\n"); } if (hfthread_create(pingTest, "PING_THREAD", 256, NULL,HFTHREAD_PRIORITIES_LOW, NULL, NULL) != HF_SUCCESS) { u_printf("create pingServer thread fail\n"); } } } }
SLOT( connectionSucceed( ) ) ); QObject::connect( p->session_, SIGNAL( disconnect( Kopete::Account::DisconnectReason ) ), SLOT( slotSessionDisconnect( Kopete::Account::DisconnectReason ) ) ); QObject::connect( p->session_, SIGNAL( ackReceived( unsigned int ) ), SLOT( ackReceived( unsigned int ) ) ); QObject::connect( p->session_, SIGNAL( pubDirSearchResult( const SearchResult&, unsigned int ) ), SLOT( slotSearchResult( const SearchResult&, unsigned int ) ) ); QObject::connect( p->session_, SIGNAL( userListExported() ), SLOT( userListExportDone() ) ); QObject::connect( p->session_, SIGNAL( userListRecieved( const QString& ) ), SLOT( userlist( const QString& ) ) ); QObject::connect( p->session_, SIGNAL( incomingCtcp( unsigned int ) ), SLOT( slotIncomingDcc( unsigned int ) ) ); QObject::connect( p->pingTimer_, SIGNAL( timeout() ), SLOT( pingServer() ) ); QObject::connect( p->exportTimer_, SIGNAL( timeout() ), SLOT( slotUserlistSynch() ) ); } void GaduAccount::setAway( bool isAway, const QString& awayMessage ) { unsigned int currentStatus; if ( isAway ) { currentStatus = ( awayMessage.isEmpty() ) ? GG_STATUS_BUSY : GG_STATUS_BUSY_DESCR; } else{ currentStatus = ( awayMessage.isEmpty() ) ? GG_STATUS_AVAIL : GG_STATUS_AVAIL_DESCR;