class Network: added 'port' to ctor parameter.
This commit is contained in:
@@ -73,7 +73,7 @@ BaseLoop::BaseLoop()
|
||||
m_busHandler->start("bushandler");
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
using namespace std;
|
||||
|
||||
extern Logger& L;
|
||||
extern Appl& A;
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
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)
|
||||
m_listening = true;
|
||||
|
||||
+2
-1
@@ -181,9 +181,10 @@ public:
|
||||
/**
|
||||
* @brief create a network instance and listening for incoming connections.
|
||||
* @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.
|
||||
*/
|
||||
Network(const bool local, WQueue<NetMessage*>* netQueue);
|
||||
Network(const bool local, const int port, WQueue<NetMessage*>* netQueue);
|
||||
|
||||
/**
|
||||
* @brief destructor.
|
||||
|
||||
Reference in New Issue
Block a user