summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Core/ConnectionManager.cpp14
-rw-r--r--src/Net/IPAddress.h7
-rw-r--r--src/Net/Listener.h14
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);
};