summaryrefslogtreecommitdiff
path: root/src/net/connectionhandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/connectionhandler.h')
-rw-r--r--src/net/connectionhandler.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/net/connectionhandler.h b/src/net/connectionhandler.h
index e49d49a9..2d0a2a6a 100644
--- a/src/net/connectionhandler.h
+++ b/src/net/connectionhandler.h
@@ -41,11 +41,12 @@ class ConnectionHandler
/**
* Open the server socket.
- * @param port the port to listen to
- * @host the host IP to listen on, defaults to the default localhost
+ *
+ * @param port the port to listen to
+ * @param hostname the host IP to listen on, defaults to the default localhost
*/
bool startListen(enet_uint16 port,
- const std::string &host = std::string());
+ const std::string &hostname = std::string());
/**
* Disconnect all the clients and close the server socket.
@@ -53,13 +54,23 @@ class ConnectionHandler
void stopListen();
/**
+ * Return the port the handler is listening on, or 0 if not listening.
+ */
+ enet_uint16 getPort() const;
+
+ /**
+ * Return the host the handler was asked to listen on.
+ */
+ const std::string &getHostname() const { return hostname; }
+
+ /**
* Process outgoing messages and listen to the server socket for
* incoming messages and new connections.
*
* @timeout an optional timeout in milliseconds to wait for something
* to happen when there is nothing to do
*/
- virtual void process(enet_uint32 timeout = 0);
+ void process(enet_uint32 timeout = 0);
/**
* Process outgoing messages.
@@ -82,8 +93,8 @@ class ConnectionHandler
unsigned getClientCount() const;
private:
- ENetAddress address; /**< Includes the port to listen to. */
- ENetHost *host; /**< The host that listen for connections. */
+ std::string hostname; /**< The unresolved host the handler was asked to listen on. */
+ ENetHost *host; /**< The ENet host that listen for connections. */
protected:
/**