diff options
Diffstat (limited to 'src/Net/IPAddress.h')
-rw-r--r-- | src/Net/IPAddress.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Net/IPAddress.h b/src/Net/IPAddress.h index e892323..c1709d5 100644 --- a/src/Net/IPAddress.h +++ b/src/Net/IPAddress.h @@ -41,6 +41,14 @@ class IPAddress { throw InvalidAddressException(address); } + IPAddress(const struct sockaddr_in &address) : sa(address) { + p = ntohs(sa.sin_port); + + char buf[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &address, buf, sizeof(buf)); + addr = buf; + } + const std::string& getAddress() const {return addr;} unsigned short getPort() const {return p;} |