diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-07-07 01:12:19 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-07-07 01:12:19 +0200 |
commit | 30f0cb9154306938250bd77ce2f0a9471065732a (patch) | |
tree | eed6304d1c07d6ea5177520e095315a8b3c6856d | |
parent | ab391a3989b15c51e5b21cbcdd4f7caff8c6ec2b (diff) | |
download | mad-30f0cb9154306938250bd77ce2f0a9471065732a.tar mad-30f0cb9154306938250bd77ce2f0a9471065732a.zip |
Benutze *-Listener, wenn keiner konfiguriert ist
-rw-r--r-- | src/Core/ConnectionManager.cpp | 14 | ||||
-rw-r--r-- | src/Net/IPAddress.h | 7 | ||||
-rw-r--r-- | src/Net/Listener.h | 14 |
3 files changed, 26 insertions, 9 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index 48d9c17..b9903c9 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -51,14 +51,24 @@ void ConnectionManager::refreshPollfds() { } ConnectionManager::ConnectionManager(const std::vector<Net::IPAddress> &listenerAddresses) { - for(std::vector<Net::IPAddress>::const_iterator address = listenerAddresses.begin(); address != listenerAddresses.end(); ++address) { + if(listenerAddresses.empty()) { try { - listeners.push_back(new Net::Listener(*address)); + listeners.push_back(new Net::Listener()); } catch(Net::Exception &e) { // TODO: Log error } } + else { + for(std::vector<Net::IPAddress>::const_iterator address = listenerAddresses.begin(); address != listenerAddresses.end(); ++address) { + try { + listeners.push_back(new Net::Listener(*address)); + } + catch(Net::Exception &e) { + // TODO: Log error + } + } + } refreshPollfds(); } diff --git a/src/Net/IPAddress.h b/src/Net/IPAddress.h index bbaae44..b0fad45 100644 --- a/src/Net/IPAddress.h +++ b/src/Net/IPAddress.h @@ -35,6 +35,13 @@ class IPAddress { struct sockaddr_in sa; public: + // TODO Default port + IPAddress(unsigned short port0 = 6666) : addr(INADDR_ANY), port(port0) { + sa.sin_family = AF_INET; + sa.sin_port = htons(port); + sa.sin_addr.s_addr = INADDR_ANY; + } + IPAddress(unsigned int address, unsigned short port0) : addr(address), port(port0) { sa.sin_family = AF_INET; sa.sin_port = htons(port); diff --git a/src/Net/Listener.h b/src/Net/Listener.h index 30fde63..81260ed 100644 --- a/src/Net/Listener.h +++ b/src/Net/Listener.h @@ -37,21 +37,21 @@ class Listener { private: IPAddress address; int sock; - + gnutls_dh_params_t dh_params; - + std::list<ServerConnection*> connections; - + // Prevent shallow copy Listener(const Listener &o); Listener& operator=(const Listener &o); - + public: - Listener(const IPAddress &address0) throw(ConnectionException); + Listener(const IPAddress &address0 = IPAddress()) throw(ConnectionException); virtual ~Listener(); - + std::vector<struct pollfd> getPollfds() const; - + ServerConnection* getConnection(const std::map<int,const short*> &pollfdMap); }; |