class Network: added 'port' to ctor parameter.

This commit is contained in:
Roland Jax
2014-12-16 15:00:45 +01:00
parent 817c54da16
commit ebde0e3032
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ BaseLoop::BaseLoop()
m_busHandler->start("bushandler"); m_busHandler->start("bushandler");
// create network // create network
m_network = new Network(A.getOptVal<bool>("localhost"), &m_netQueue); m_network = new Network(A.getOptVal<bool>("localhost"), A.getOptVal<int>("port"), &m_netQueue);
m_network->start("network"); m_network->start("network");
} }
+3 -4
View File
@@ -33,7 +33,6 @@
using namespace std; using namespace std;
extern Logger& L; extern Logger& L;
extern Appl& A;
int Connection::m_ids = 0; int Connection::m_ids = 0;
@@ -144,13 +143,13 @@ void Connection::run()
} }
Network::Network(const bool local, WQueue<NetMessage*>* netQueue) Network::Network(const bool local, const int port, WQueue<NetMessage*>* netQueue)
: m_netQueue(netQueue), m_listening(false) : m_netQueue(netQueue), m_listening(false)
{ {
if (local == true) if (local == true)
m_tcpServer = new TCPServer(A.getOptVal<int>("port"), "127.0.0.1"); m_tcpServer = new TCPServer(port, "127.0.0.1");
else else
m_tcpServer = new TCPServer(A.getOptVal<int>("port"), "0.0.0.0"); m_tcpServer = new TCPServer(port, "0.0.0.0");
if (m_tcpServer != NULL && m_tcpServer->start() == 0) if (m_tcpServer != NULL && m_tcpServer->start() == 0)
m_listening = true; m_listening = true;
+2 -1
View File
@@ -181,9 +181,10 @@ public:
/** /**
* @brief create a network instance and listening for incoming connections. * @brief create a network instance and listening for incoming connections.
* @param local true to accept connections only for local host. * @param local true to accept connections only for local host.
* @param port the tcp port to listening.
* @param netQueue the remote queue for network messages. * @param netQueue the remote queue for network messages.
*/ */
Network(const bool local, WQueue<NetMessage*>* netQueue); Network(const bool local, const int port, WQueue<NetMessage*>* netQueue);
/** /**
* @brief destructor. * @brief destructor.