X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fsocket.cpp;h=ac4871f6145524059f4ed73b1d2de0a1864a7f59;hb=ef08163c38ea668f509015c176a59d6f4ae1fd76;hp=499ee504e0d7e33c3c793577a5f040b2971a8486;hpb=c32da52104cc6bbe8ed0bf1ba1a7874f015cb738;p=dragonfireclient.git diff --git a/src/socket.cpp b/src/socket.cpp index 499ee504e..ac4871f61 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -26,7 +26,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "utility.h" // Debug printing options +// Set to 1 for debug output #define DP 0 +// This is prepended to everything printed here #define DPS "" bool g_sockets_initialized = false; @@ -51,6 +53,8 @@ void sockets_cleanup() Address::Address() { + m_address = 0; + m_port = 0; } Address::Address(unsigned int address, unsigned short port) @@ -93,6 +97,16 @@ void Address::Resolve(const char *name) freeaddrinfo(resolved); } +std::string Address::serializeString() +{ + unsigned int a, b, c, d; + a = (m_address & 0xFF000000)>>24; + b = (m_address & 0x00FF0000)>>16; + c = (m_address & 0x0000FF00)>>8; + d = (m_address & 0x000000FF); + return itos(a)+"."+itos(b)+"."+itos(c)+"."+itos(d); +} + unsigned int Address::getAddress() const { return m_address; @@ -108,6 +122,12 @@ void Address::setAddress(unsigned int address) m_address = address; } +void Address::setAddress(unsigned int a, unsigned int b, + unsigned int c, unsigned int d) +{ + m_address = (a<<24) | (b<<16) | ( c<<8) | d; +} + void Address::setPort(unsigned short port) { m_port = port;