From 610ececb74d5efb4ed4df54dbceaa54fcbcf99e5 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 24 May 2009 17:20:36 +0200 Subject: 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'. --- src/net/connectionhandler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/net/connectionhandler.cpp') diff --git a/src/net/connectionhandler.cpp b/src/net/connectionhandler.cpp index 123dc0b..22fadc4 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() -- cgit