// ------------------------------------------------------------- // bindSocket() -- bind the socket to an address, and configure // the send and receive buffers. // ------------------------------------------------------------- bool UdpUnicastHandler::bindSocket() { // --- // Our base class will bind the socket // --- bool ok = BaseClass::bindSocket(); if (ok) { struct sockaddr_in addr; // Working address structure bzero(&addr, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = getLocalAddr(); if (getLocalPort() != 0) addr.sin_port = htons (getLocalPort()); else addr.sin_port = htons(getPort()); if (::bind(socketNum, reinterpret_cast<const struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) { std::perror("UdpUnicastHandler::bindSocket(): bind error"); return false; } if (!setSendBuffSize()) return false; if (!setRecvBuffSize()) return false; } return ok; }
std::string SIPAccount::getTransportMapKey (void) const { std::stringstream out; out << getLocalPort(); std::string localPort = out.str(); return localPort; }
//============================================================================== // PlainDatagramSocketImpl::toString // //============================================================================== String PlainDatagramSocketImpl::toString() const { String ret = QC_T("addr="); ret += getInetAddress()->toString(); ret += QC_T(",port="); ret += NumUtils::ToString(getPort()); ret += QC_T(",localport="); ret += NumUtils::ToString(getLocalPort()); return ret; }
bool ServerServiceAsync::onInitialise() { // 初始化minidump MiniDump::InitMiniDump("./crashlog/", mName.c_str()); // 初始化日志 string strLogFile = strformat("./log/%s/%s", mName.c_str(), mName.c_str()); ServerLogger::getInstance().start(strLogFile.c_str(), "super", true); loadConfig(); mLocalPort = 7102; // 开启服务 addTimer(new TimerForMain); start( getLocalPort() ); updateWindowTitle(); LOGI("开始监听端口 %d", getLocalPort()); return true; }
UdpClient::UdpClient(GameScreen* gs) { this->gs = gs; receiveTrigger = false; //if (socket.bind(serverPort + 1) != sf::Socket::Done) { if (socket.bind(sf::Socket::AnyPort) != sf::Socket::Done) { printf("Error while binding in UdpClient::UdpClient(GameScreen* gs)\n"); } send((UdpPacket*) new UdpHandshakePacket()); printf("Bind UDP socket on port %d\n", getLocalPort()); socket.setBlocking(true); }
int Socket::listen(const SocketAddress& addr, int backlog) const { createSocket(addr); const SOCKET& socket = impl->fd; BOOL yes=1; QPID_WINSOCK_CHECK(setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes))); if (::bind(socket, getAddrInfo(addr).ai_addr, getAddrInfo(addr).ai_addrlen) == SOCKET_ERROR) throw Exception(QPID_MSG("Can't bind to " << addr.asString() << ": " << strError(WSAGetLastError()))); if (::listen(socket, backlog) == SOCKET_ERROR) throw Exception(QPID_MSG("Can't listen on " <<addr.asString() << ": " << strError(WSAGetLastError()))); return getLocalPort(socket); }
void _pmdExternClient::logout() { if ( _isAuthed ) { CHAR szTmp[ 16 ] = { 0 } ; ossSnprintf( szTmp, sizeof(szTmp)-1, "%llu", _pEDUCB->getID() ) ; PD_AUDIT( AUDIT_ACCESS, getUsername(), getPeerIPAddr(), getPeerPort(), "LOGOUT", AUDIT_OBJ_SESSION, szTmp, SDB_OK, "User[UserName:%s, RemoteIP:%s, RemotePort:%u, " "LocalIP:%s, LocalPort:%u] logout succeed", getUsername(), getPeerIPAddr(), getPeerPort(), getLocalIPAddr(), getLocalPort() ) ; } _isAuthed = FALSE ; }
void ServerServiceSync::updateWindowTitle() { string strTitle = strformat("ServerService %d",getLocalPort()); strTitle = Platform::utf8ToGbk(strTitle); Platform::setWindowTitle(strTitle.c_str()); ////////////////////////////////////////////////////////////////////////// //google::protobuf::Message* newQuery = createMessage("LoginCmd.RequestRegisterGameServer"); //assert(newQuery != NULL); //LoginCmd::RequestRegisterGameServer::default_instance(); //LoginCmd::RequestRegisterGameServer cmd; //LoginCmd::RequestRegisterGameServer* pMsg = (LoginCmd::RequestRegisterGameServer*)createMessage("LoginCmd.RequestRegisterGameServer"); //pMsg->set_id(1); //IterateProtoFile("ProtoSvrLogin.proto"); }
bool CDStarRepeaterConfigNetworkSet::Validate() { unsigned int port = getGatewayPort(); if (port == 0U || port > 65535U) { wxMessageDialog dialog(this, _("The Gateway Port is not valid"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } port = getLocalPort(); if (port == 0U || port > 65535U) { wxMessageDialog dialog(this, _("The Local Port is not valid"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } return true; }
bool CDExtraGatewayRepeaterSet::Validate() { wxString callsign = getRepeaterCallsign(); if (callsign.IsEmpty()) { wxMessageDialog dialog(this, _("The Repeater Callsign is not valid"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } wxString address = getRepeaterAddress(); if (address.IsEmpty()) { wxMessageDialog dialog(this, _("The Repeater Address is not valid"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } unsigned int port = getRepeaterPort(); if (port == 0U || port > 65535U) { wxMessageDialog dialog(this, _("The Repeater Port is not valid"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } port = getLocalPort(); if (port == 0U || port > 65535U) { wxMessageDialog dialog(this, _("The Local Port is not valid"), m_title + _(" Error"), wxICON_ERROR); dialog.ShowModal(); return false; } return true; }
void AtDrv::startClient(uint8_t sock, uint32_t ipAddress, uint16_t port, uint8_t protMode) { // if we enable CHECK_TCP_STATE feature, always call reConnect(), or we won't get right // tcp port status, since we disable tcp auto reconnect. #ifndef CHECK_TCP_STATE bool needReConn = false; #else bool needReConn = true; #endif int curMode; uint32_t curIp; uint8_t curProtocol; uint16_t curPort; uint16_t curLocalPort; uint32_t curTimeout; bool curTcpAuto; // clear uart buffer first stopClient(sock); if(!isAtMode()) { if(!switchToAtMode()) { INFO1("Can't switch to at mode"); goto end; } } if(!getMode(sock, &curMode) || curMode != MODE_CLIENT) { needReConn = true; INFO1("curMode != MODE_CLIENT"); if(!setMode(sock, MODE_CLIENT)) { INFO1("Can't set mode"); goto end; } } if(!getRemoteIp(sock, (uint8_t *)&curIp) || curIp != ipAddress) { needReConn = true; INFO1("curIp != ipAddress"); if(!setRemoteIp(sock, ipAddress)) { INFO1("Can't set ip"); goto end; } } if(!getProtocol(sock, &curProtocol) || curProtocol != protMode) { needReConn = true; INFO1("curProtocol != protMode"); if(!setProtocol(sock, protMode)) { INFO1("Can't set protocol"); goto end; } } if(!getRemotePort(sock, &curPort) || curPort != port) { needReConn = true; INFO1("curPort != port"); if(!setPort(sock, port)) { INFO1("Can't set port"); goto end; } } if(!getTcpAuto(sock, &curTcpAuto) || curTcpAuto != false) { needReConn = true; INFO1("curTcpAuto != false"); if(!setTcpAuto(sock, false)) { INFO1("Can't set tcp auto"); goto end; } } if(!getLocalPort(sock, &curLocalPort) || curLocalPort != localSockPort[sock]) { needReConn = true; INFO1("curLocalPort != port"); if(!setLocalPort(sock, localSockPort[sock])) { INFO1("Can't set port"); goto end; } } if(needReConn) { if(!reConnect()) { INFO1("Can't reconnect"); goto end; } } sockPort[sock] = localSockPort[sock]; sockConnected[sock] = true; end: return; }
unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* socket) { CSFML_CALL_RETURN(socket, getLocalPort(), 0); }
uint16_t AsyncClient::localPort() { return getLocalPort(); }
std::map<std::string, std::string> SIPAccount::getAccountDetails() const { std::map<std::string, std::string> a; a[ACCOUNT_ID] = _accountID; // The IP profile does not allow to set an alias a[CONFIG_ACCOUNT_ALIAS] = (_accountID == IP2IP_PROFILE) ? IP2IP_PROFILE : getAlias(); a[CONFIG_ACCOUNT_ENABLE] = isEnabled() ? "true" : "false"; a[CONFIG_ACCOUNT_TYPE] = getType(); a[HOSTNAME] = getHostname(); a[USERNAME] = getUsername(); a[CONFIG_RINGTONE_PATH] = getRingtonePath(); a[CONFIG_RINGTONE_ENABLED] = getRingtoneEnabled() ? "true" : "false"; a[CONFIG_ACCOUNT_MAILBOX] = getMailBox(); RegistrationState state = Unregistered; std::string registrationStateCode; std::string registrationStateDescription; if (_accountID == IP2IP_PROFILE) { registrationStateCode = ""; // emtpy field registrationStateDescription = "Direct IP call"; } else { state = getRegistrationState(); int code = getRegistrationStateDetailed().first; std::stringstream out; out << code; registrationStateCode = out.str(); registrationStateDescription = getRegistrationStateDetailed().second; } a[REGISTRATION_STATUS] = (_accountID == IP2IP_PROFILE) ? "READY": Manager::instance().mapStateNumberToString (state); a[REGISTRATION_STATE_CODE] = registrationStateCode; a[REGISTRATION_STATE_DESCRIPTION] = registrationStateDescription; // Add sip specific details a[ROUTESET] = getServiceRoute(); a[CONFIG_ACCOUNT_RESOLVE_ONCE] = isResolveOnce() ? "true" : "false"; a[USERAGENT] = getUseragent(); a[CONFIG_ACCOUNT_REGISTRATION_EXPIRE] = getRegistrationExpire(); a[LOCAL_INTERFACE] = getLocalInterface(); a[PUBLISHED_SAMEAS_LOCAL] = getPublishedSameasLocal() ? "true" : "false"; a[PUBLISHED_ADDRESS] = getPublishedAddress(); std::stringstream localport; localport << getLocalPort(); a[LOCAL_PORT] = localport.str(); std::stringstream publishedport; publishedport << getPublishedPort(); a[PUBLISHED_PORT] = publishedport.str(); a[STUN_ENABLE] = isStunEnabled() ? "true" : "false"; a[STUN_SERVER] = getStunServer(); a[ACCOUNT_DTMF_TYPE] = (getDtmfType() == OVERRTP) ? "overrtp" : "sipinfo"; a[SRTP_KEY_EXCHANGE] = getSrtpKeyExchange(); a[SRTP_ENABLE] = getSrtpEnable() ? "true" : "false"; a[SRTP_RTP_FALLBACK] = getSrtpFallback() ? "true" : "false"; a[ZRTP_DISPLAY_SAS] = getZrtpDisplaySas() ? "true" : "false"; a[ZRTP_DISPLAY_SAS_ONCE] = getZrtpDiaplaySasOnce() ? "true" : "false"; a[ZRTP_HELLO_HASH] = getZrtpHelloHash() ? "true" : "false"; a[ZRTP_NOT_SUPP_WARNING] = getZrtpNotSuppWarning() ? "true" : "false"; // TLS listener is unique and parameters are modified through IP2IP_PROFILE std::stringstream tlslistenerport; tlslistenerport << getTlsListenerPort(); a[TLS_LISTENER_PORT] = tlslistenerport.str(); a[TLS_ENABLE] = getTlsEnable(); a[TLS_CA_LIST_FILE] = getTlsCaListFile(); a[TLS_CERTIFICATE_FILE] = getTlsCertificateFile(); a[TLS_PRIVATE_KEY_FILE] = getTlsPrivateKeyFile(); a[TLS_PASSWORD] = getTlsPassword(); a[TLS_METHOD] = getTlsMethod(); a[TLS_CIPHERS] = getTlsCiphers(); a[TLS_SERVER_NAME] = getTlsServerName(); a[TLS_VERIFY_SERVER] = getTlsVerifyServer() ? "true" : "false"; a[TLS_VERIFY_CLIENT] = getTlsVerifyClient() ? "true" : "false"; a[TLS_REQUIRE_CLIENT_CERTIFICATE] = getTlsRequireClientCertificate() ? "true" : "false"; a[TLS_NEGOTIATION_TIMEOUT_SEC] = getTlsNegotiationTimeoutSec(); a[TLS_NEGOTIATION_TIMEOUT_MSEC] = getTlsNegotiationTimeoutMsec(); return a; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_OSSSK_CONNECT, "ossSocket::connect" ) INT32 _ossSocket::connect ( INT32 timeout ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_OSSSK_CONNECT ); SDB_ASSERT ( !_peerAddress.sin_addr.s_addr, "Cannot connect without close/init" ) ; #if defined (_LINUX) INT32 flags = fcntl( native(), F_GETFL, 0) ; if ( fcntl( native(), F_SETFL, flags | O_NONBLOCK ) <0 ) { PD_LOG( PDERROR, "failed to fcntl sock:%d",native() ) ; rc = SDB_SYS ; goto error ; } rc = ::connect ( _fd, (struct sockaddr *) &_sockAddress, _addressLen ) ; if ( rc != SDB_OK ) { if ( SOCKET_GETLASTERROR == EINPROGRESS ) { rc = _complete( timeout ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "Failed to complete connect, rc = %d", rc ) ; goto error ; } } else { PD_LOG ( PDERROR, "Failed to connect, rc = %d", SOCKET_GETLASTERROR ) ; rc = SDB_NETWORK ; goto error ; } } else { } if ( fcntl( native(), F_SETFL, flags & ~O_NONBLOCK ) <0 ) { PD_LOG( PDERROR, "failed to fcntl sock:%d",native() ) ; close() ; rc = SDB_SYS ; goto error ; } #elif defined (_WINDOWS) rc = ::connect ( _fd, (struct sockaddr *) &_sockAddress, _addressLen ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to connect, rc = %d", SOCKET_GETLASTERROR ) ; rc = SDB_NETWORK ; goto error ; } #endif rc = getsockname ( _fd, (sockaddr*)&_sockAddress, &_addressLen ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to get local address, rc=%d", rc ) ; rc = SDB_NETWORK ; goto error ; } rc = getpeername ( _fd, (sockaddr*)&_peerAddress, &_peerAddressLen ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to get peer address, rc=%d", rc ) ; rc = SDB_NETWORK ; goto error ; } if ( _sockAddress.sin_port == _peerAddress.sin_port && _sockAddress.sin_addr.s_addr == _peerAddress.sin_addr.s_addr ) { PD_LOG( PDERROR, "Local addr is the same with remote addr, " "local port: %u, remote port: %u", getLocalPort(), getPeerPort() ) ; rc = SDB_NETWORK ; goto error ; } done : PD_TRACE_EXITRC ( SDB_OSSSK_CONNECT, rc ); return rc ; error : close() ; goto done ; }
INT32 _pmdExternClient::authenticate( MsgHeader *pMsg ) { #if defined ( SDB_ENGINE ) INT32 rc = SDB_OK ; BSONObj authObj ; BSONElement user, pass ; rc = extractAuthMsg( pMsg, authObj ) ; if ( rc ) { PD_LOG( PDERROR, "Client[%s] extract auth msg failed, rc: %d", clientName(), rc ) ; goto error ; } user = authObj.getField( SDB_AUTH_USER ) ; pass = authObj.getField( SDB_AUTH_PASSWD ) ; _isAuthed = FALSE ; if ( SDB_ROLE_STANDALONE == pmdGetDBRole() ) // not auth { _isAuthed = TRUE ; goto done ; } else if ( SDB_ROLE_OM == pmdGetDBRole() ) { rc = sdbGetOMManager()->authenticate( authObj, _pEDUCB ) ; if ( rc ) { PD_LOG( PDERROR, "Client[%s] authenticate failed[user: %s, " "passwd: %s], rc: %d", clientName(), user.valuestrsafe(), pass.valuestrsafe(), rc ) ; goto error ; } _isAuthed = TRUE ; } else if ( SDB_ROLE_COORD == pmdGetDBRole() ) { INT64 contextID = -1 ; rtnContextBuf buf ; CoordCB *pCoordcb = pmdGetKRCB()->getCoordCB(); rtnCoordProcesserFactory *pProcesserFactory = pCoordcb->getProcesserFactory(); rtnCoordOperator *pOperator = NULL ; pOperator = pProcesserFactory->getOperator( pMsg->opCode ); rc = pOperator->execute( pMsg, _pEDUCB, contextID, &buf ) ; // special handling for password verification when there is no // addrlist specified. Usually this happen when there is only // one coord node before creating the first catalog if ( MSG_AUTH_VERIFY_REQ == pMsg->opCode && SDB_CAT_NO_ADDR_LIST == rc ) { rc = SDB_OK ; _isAuthed = TRUE ; } else if ( rc ) { PD_LOG( PDERROR, "Client[%s] authenticate failed[user: %s, " "passwd: %s], rc: %d", clientName(), user.valuestrsafe(), pass.valuestrsafe(), rc ) ; goto error ; } else { _isAuthed = TRUE ; } } else { MsgHeader *pAuthRes = NULL ; shardCB *pShard = sdbGetShardCB() ; UINT32 retryTimes = 0 ; MsgOpReply replyHeader ; replyHeader.contextID = -1 ; replyHeader.numReturned = 0 ; while ( TRUE ) { ++retryTimes ; rc = pShard->syncSend( pMsg, CATALOG_GROUPID, TRUE, &pAuthRes ) ; if ( SDB_OK != rc ) { rc = pShard->syncSend( pMsg, CATALOG_GROUPID, FALSE, &pAuthRes ) ; PD_RC_CHECK( rc, PDERROR, "Client[%s] failed to send auth " "req to catalog, rc: %d", clientName(), rc ) ; } if ( NULL == pAuthRes ) { rc = SDB_SYS ; PD_LOG( PDERROR, "syncsend return ok but res is NULL" ) ; goto error ; } rc = MSG_GET_INNER_REPLY_RC(pAuthRes) ; replyHeader.flags = rc ; replyHeader.startFrom = MSG_GET_INNER_REPLY_STARTFROM(pAuthRes) ; ossMemcpy( &(replyHeader.header), pAuthRes, sizeof( MsgHeader ) ) ; /// release recv msg SDB_OSS_FREE( (BYTE*)pAuthRes ) ; pAuthRes = NULL ; if ( SDB_CLS_NOT_PRIMARY == rc && retryTimes < PMD_AUTH_RETRY_TIMES ) { INT32 rcTmp = SDB_OK ; rcTmp = pShard->updatePrimaryByReply( &(replyHeader.header) ) ; if ( SDB_NET_CANNOT_CONNECT == rcTmp ) { /// the node is crashed, sleep some seconds PD_LOG( PDWARNING, "Catalog group primary node is crashed " "but other nodes not aware, sleep %d seconds", NET_NODE_FAULTUP_MIN_TIME ) ; ossSleep( NET_NODE_FAULTUP_MIN_TIME * OSS_ONE_SEC ) ; } if ( rcTmp ) { pShard->updateCatGroup( CLS_SHARD_TIMEOUT ) ; } continue ; } else if ( rc ) { PD_LOG( PDERROR, "Client[%s] authenticate failed[user: %s, " "passwd: %s], rc: %d", clientName(), user.valuestrsafe(), pass.valuestrsafe(), rc ) ; goto error ; } else { _isAuthed = TRUE ; } break ; } } done: if ( SDB_OK == rc && _isAuthed ) { _username = user.valuestrsafe() ; if ( !_username.empty() ) { _password = pass.valuestrsafe() ; } _pEDUCB->setUserInfo( _username, _password ) ; _makeName() ; CHAR szTmp[ 16 ] = { 0 } ; ossSnprintf( szTmp, sizeof(szTmp)-1, "%llu", _pEDUCB->getID() ) ; PD_AUDIT_OP( AUDIT_ACCESS, MSG_AUTH_VERIFY_REQ, AUDIT_OBJ_SESSION, szTmp, SDB_OK, "User[UserName:%s, RemoteIP:%s, RemotePort:%u, " "LocalIP:%s, LocalPort:%u] login succeed", getUsername(), getPeerIPAddr(), getPeerPort(), getLocalIPAddr(), getLocalPort() ) ; } return rc ; error: if ( SDB_AUTH_AUTHORITY_FORBIDDEN == rc ) { _pEDUCB->printInfo( EDU_INFO_ERROR, "username or passwd is wrong" ) ; } goto done ; #else _isAuthed = TRUE ; return SDB_OK ; #endif // SDB_ENGINE }
int Cconfigurator::saveConfigAs(QByteArray path, QByteArray filename) { unsigned int i; // try QSettings QSettings conf(path + filename, QSettings::IniFormat); conf.beginGroup("General"); conf.setValue("mapFile", getBaseFile()); conf.setValue("windowRect", renderer_window->geometry() ); conf.setValue("alwaysOnTop", getAlwaysOnTop() ); conf.setValue("startupMode", getStartupMode() ); conf.endGroup(); conf.beginGroup("Networking"); conf.setValue("localPort", getLocalPort() ); conf.setValue("remoteHost", getRemoteHost() ); conf.setValue("remotePort", getRemotePort() ); conf.endGroup(); conf.beginGroup("OpenGL"); conf.setValue("texturesVisibility", getTextureVisibility() ); conf.setValue("detailsVisibility", getDetailsVisibility() ); conf.setValue("visibleLayers", getVisibleLayers() ); conf.setValue("showNotes", getShowNotesRenderer() ); conf.setValue("showRegions", getShowRegionsInfo() ); conf.setValue("displayRegions", getDisplayRegionsRenderer() ); conf.setValue("multisampling", getMultisampling() ); conf.setValue("selectOnAnyLayer", getSelectOAnyLayer()); conf.setValue("angleX", (double) angleX ); conf.setValue("angleY", (double) angleY ); conf.setValue("angleZ", (double) angleZ ); conf.setValue("userX", (double) userX ); conf.setValue("userY", (double) userY ); conf.setValue("userZ", (double) userZ ); conf.setValue("noteColor", getNoteColor() ); conf.setValue("drawPrespam", getDrawPrespam()); conf.endGroup(); conf.beginGroup("Engine"); conf.setValue("checkExits", getExitsCheck() ); conf.setValue("checkTerrain", getTerrainCheck() ); conf.setValue("briefmode", getBriefMode() ); conf.setValue("autoMerge", getAutomerge() ); conf.setValue("angryLinker", getAngrylinker() ); conf.setValue("dualLinker", getDuallinker() ); conf.setValue("autoRefresh", getAutorefresh() ); conf.setValue("roomNameQuote", getNameQuote() ); conf.setValue("descQuote", getDescQuote() ); conf.setValue("mactionUsesPrespam", getMactionUsesPrespam()); conf.setValue("prespamTTL", getPrespamTTL()); conf.endGroup(); conf.beginGroup("Patterns"); conf.setValue("exitsPattern", getExitsPattern()); conf.setValue("spellsEffectPattern", spells_pattern); conf.setValue( "scorePattern", getScorePattern() ); conf.setValue( "scorePatternShort", getShortScorePattern() ); conf.endGroup(); conf.beginGroup("GroupManager"); conf.setValue("remoteHost", getGroupManagerHost() ); conf.setValue("remotePort", getGroupManagerRemotePort() ); conf.setValue("localServerPort", getGroupManagerLocalPort() ); conf.setValue("charName", getGroupManagerCharName() ); conf.setValue("charColor", getGroupManagerColor().name() ); conf.setValue("showSelf", getGroupManagerShowSelf() ); conf.setValue("notifyArm", getGroupManagerNotifyArmour() ); conf.setValue("notifySanc", getGroupManagerNotifySanc() ); conf.setValue("notifyBash", getGroupManagerNotifyBash() ); conf.setValue("showGroupManager", getGroupManagerShowManager() ); conf.setValue("windowRect", renderer_window->getGroupManagerRect() ); conf.endGroup(); conf.beginWriteArray("Spells"); for (unsigned int i = 0; i < spells.size(); ++i) { conf.setArrayIndex(i); conf.setValue("addon", spells[i].addon); conf.setValue("name", spells[i].name); conf.setValue("upMessage", spells[i].up_mes); conf.setValue("refreshMessage", spells[i].refresh_mes); conf.setValue("downMessage", spells[i].down_mes); } conf.endArray(); conf.beginGroup("Movement tracking"); conf.beginWriteArray("Cancel Patterns"); for (int i = 0; i < moveCancelPatterns.size(); ++i) { conf.setArrayIndex(i); conf.setValue("pattern", moveCancelPatterns.at(i)); } conf.endArray(); conf.beginWriteArray("Force Patterns"); for (int i = 0; i < moveForcePatterns.size(); ++i) { conf.setArrayIndex(i); conf.setValue("pattern", moveForcePatterns.at(i)); } conf.endArray(); conf.endGroup(); conf.beginWriteArray("Debug Settings"); i = 0; while (debug_data[i].name) { conf.setArrayIndex(i); conf.setValue("name", debug_data[i].name); conf.setValue("state", debug_data[i].state); i++; } conf.endArray(); configFile = filename; configPath = path; setConfigModified(false); return true; }
void AtDrv::startClient(uint8_t sock, const char *host, uint16_t port, uint8_t protMode) { // if we enable CHECK_TCP_STATE feature, always call reConnect(), or we won't get right // tcp port status, since we disable tcp auto reconnect. #ifndef CHECK_TCP_STATE bool needReConn = false; #else bool needReConn = true; #endif int curMode; char curHostBuf[MAX_HOST_NAME_BUF_SIZE]; uint8_t curProtocol; uint16_t curPort; uint16_t curLocalPort; uint32_t curTimeout; bool curTcpAuto; // clear uart buffer first stopClient(sock); if(!isAtMode()) { if(!switchToAtMode()) { INFO1("Can't switch to at mode"); goto end; } } if(!getMode(sock, &curMode) || curMode != MODE_CLIENT) { needReConn = true; INFO1("curMode != MODE_CLIENT"); if(!setMode(sock, MODE_CLIENT)) { INFO1("Can't set mode"); goto end; } } if(!getRemoteHost(sock, curHostBuf) || (strcmp(curHostBuf, host) != 0)) { needReConn = true; INFO1("curHostBuf != host"); if(!setRemoteHost(sock, host)) { INFO1("Can't set host"); goto end; } } if(!getProtocol(sock, &curProtocol) || curProtocol != protMode) { needReConn = true; INFO1("curProtocol != protMode"); if(!setProtocol(sock, protMode)) { INFO1("Can't set protocol"); goto end; } } if(!getRemotePort(sock, &curPort) || curPort != port) { needReConn = true; INFO1("curPort != port"); if(!setPort(sock, port)) { INFO1("Can't set port"); goto end; } } if(!getTcpAuto(sock, &curTcpAuto) || curTcpAuto != false) { needReConn = true; INFO1("curTcpAuto != false"); if(!setTcpAuto(sock, false)) { INFO1("Can't set tcp auto"); goto end; } } if(!getLocalPort(sock, &curLocalPort) || curLocalPort != localSockPort[sock]) { needReConn = true; INFO1("curLocalPort != port"); if(!setLocalPort(sock, localSockPort[sock])) { INFO1("Can't set port"); goto end; } } if(needReConn) { if(!reConnect()) { INFO1("Can't reconnect"); goto end; } } sockPort[sock] = localSockPort[sock]; sockConnected[sock] = true; end: return; }
sp<InetSocketAddress> ServerSocket::getLocalSocketAddress() const { if (!isBound()) { return nullptr; } return new InetSocketAddress(mLocalAddress, getLocalPort()); }
void ServerServiceAsync::updateWindowTitle() { string strTitle = strformat("ServerService %d",getLocalPort()); strTitle = Platform::utf8ToGbk(strTitle); Platform::setWindowTitle(strTitle.c_str()); }