diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-10-16 00:37:21 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-10-16 00:37:25 +0200 |
commit | eda94456add9a65d1821302e343bef4021d2a773 (patch) | |
tree | 237e09b79c0e8b853b0892deca8b67713a8c4634 /include/sibs/IpAddress.hpp | |
parent | 29d93a061a8fcc36e5d7afd1dbcd0a6fefbbabaa (diff) |
Reuse peer connection if subscribed to same key
Diffstat (limited to 'include/sibs/IpAddress.hpp')
-rw-r--r-- | include/sibs/IpAddress.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/sibs/IpAddress.hpp b/include/sibs/IpAddress.hpp index c3b43c4..4403e83 100644 --- a/include/sibs/IpAddress.hpp +++ b/include/sibs/IpAddress.hpp @@ -2,6 +2,7 @@ #include <stdexcept> #include <string> +#include <unordered_map> #ifndef WIN32 #include <arpa/inet.h> #include <netdb.h> @@ -32,7 +33,19 @@ namespace sibs unsigned short getPort() const; bool operator == (const Ipv4 &other) const; + bool operator != (const Ipv4 &other) const; struct sockaddr_in address; }; + + struct Ipv4Hasher + { + size_t operator()(const Ipv4 &address) const + { + return address.address.sin_addr.s_addr ^ address.address.sin_port; + } + }; + + template <typename ValueType> + using Ipv4Map = std::unordered_map<Ipv4, ValueType, Ipv4Hasher>; } |