diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-16 00:37:21 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | c47870421f189eb98fc66e912693d73fbd8477ee (patch) | |
tree | 036ead590fa17bef279de483489a880c54ef4ba1 /include/sibs/IpAddress.hpp | |
parent | 0c1b3db7c4d9a4bcde4160c437613b32cd4081d6 (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>; } |