- no need to crash if admin port already in use, just output error to console

This commit is contained in:
Mark Vejvoda 2012-11-15 15:08:30 +00:00
parent 3773736212
commit 07c2af4b99
2 changed files with 16 additions and 8 deletions

View File

@ -84,7 +84,7 @@ bool NetworkManager::isNetworkGame() {
GameNetworkInterface* NetworkManager::getGameNetworkInterface(bool throwErrorOnNull) {
if(throwErrorOnNull) {
assert(gameNetworkInterface!=NULL);
//assert(gameNetworkInterface!=NULL);
if(gameNetworkInterface==NULL) {
throw megaglest_runtime_error("gameNetworkInterface==NULL");
@ -95,7 +95,7 @@ GameNetworkInterface* NetworkManager::getGameNetworkInterface(bool throwErrorOnN
ServerInterface* NetworkManager::getServerInterface(bool throwErrorOnNull) {
if(throwErrorOnNull) {
assert(gameNetworkInterface!=NULL);
//assert(gameNetworkInterface!=NULL);
if(gameNetworkInterface==NULL) {
throw megaglest_runtime_error("gameNetworkInterface==NULL");
}
@ -112,7 +112,7 @@ ClientInterface* NetworkManager::getClientInterface(bool throwErrorOnNull) {
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
if(throwErrorOnNull) {
assert(gameNetworkInterface!=NULL);
//assert(gameNetworkInterface!=NULL);
if(gameNetworkInterface==NULL) {
throw megaglest_runtime_error("gameNetworkInterface==NULL");
}

View File

@ -78,11 +78,19 @@ ServerInterface::ServerInterface(bool publishEnabled) :GameNetworkInterface() {
// This is an admin port listening only on the localhost intended to
// give current connection status info
#ifndef __APPLE__
serverSocketAdmin = new ServerSocket(true);
serverSocketAdmin->setBlock(false);
serverSocketAdmin->setBindPort(Config::getInstance().getInt("ServerAdminPort", intToStr(GameConstants::serverAdminPort).c_str()));
serverSocketAdmin->setBindSpecificAddress(Config::getInstance().getString("ServerAdminBindAddress", "127.0.0.1"));
serverSocketAdmin->listen(5);
try {
serverSocketAdmin = new ServerSocket(true);
serverSocketAdmin->setBlock(false);
serverSocketAdmin->setBindPort(Config::getInstance().getInt("ServerAdminPort", intToStr(GameConstants::serverAdminPort).c_str()));
serverSocketAdmin->setBindSpecificAddress(Config::getInstance().getString("ServerAdminBindAddress", "127.0.0.1"));
serverSocketAdmin->listen(5);
}
catch(const std::exception &ex) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d] Warning Server admin port bind/listen error:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
}
#endif
maxFrameCountLagAllowed = Config::getInstance().getInt("MaxFrameCountLagAllowed", intToStr(maxFrameCountLagAllowed).c_str());