summaryrefslogtreecommitdiff
path: root/src/net/connectionhandler.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-24 17:20:36 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-24 17:20:36 +0200
commit610ececb74d5efb4ed4df54dbceaa54fcbcf99e5 (patch)
tree4cfa485ebd00103bcb7cd7c139435bc0c92088e4 /src/net/connectionhandler.cpp
parentaf12180611e2c0520ee4974d5246e474fd8e704e (diff)
downloadmanaserv-610ececb74d5efb4ed4df54dbceaa54fcbcf99e5.tar.gz
manaserv-610ececb74d5efb4ed4df54dbceaa54fcbcf99e5.tar.bz2
manaserv-610ececb74d5efb4ed4df54dbceaa54fcbcf99e5.tar.xz
manaserv-610ececb74d5efb4ed4df54dbceaa54fcbcf99e5.zip
Made it possible to specify the host to listen on
Needed when the server has multiple network interfaces and the one you want to use isn't the default one for localhost. The host to listen on can be set in config file with 'net_listenHost'.
Diffstat (limited to 'src/net/connectionhandler.cpp')
-rw-r--r--src/net/connectionhandler.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net/connectionhandler.cpp b/src/net/connectionhandler.cpp
index 123dc0b7..22fadc4c 100644
--- a/src/net/connectionhandler.cpp
+++ b/src/net/connectionhandler.cpp
@@ -30,12 +30,16 @@
#include "net/netcomputer.hpp"
#include "utils/logger.h"
-bool ConnectionHandler::startListen(enet_uint16 port)
+bool ConnectionHandler::startListen(enet_uint16 port,
+ const std::string &listenHost)
{
// Bind the server to the default localhost.
address.host = ENET_HOST_ANY;
address.port = port;
+ if (!listenHost.empty())
+ enet_address_set_host(&address, listenHost.c_str());
+
LOG_INFO("Listening on port " << port << "...");
host = enet_host_create(
&address /* the address to bind the server host to */,
@@ -43,7 +47,7 @@ bool ConnectionHandler::startListen(enet_uint16 port)
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
- return host;
+ return host != 0;
}
void ConnectionHandler::stopListen()