Thu, 11 Dec 2014 06:13:32 +0200
- fixed some problems with the ip address
#pragma once #include "../main.h" struct sockaddr; struct sockaddr_in; enum WithPort { IP_WITH_PORT, IP_NO_PORT }; struct IPAddress { unsigned long host; unsigned short port; static bool sink; IPAddress(); IPAddress (unsigned long host, unsigned short port); IPAddress (const IPAddress& other); METHOD compare (const IPAddress& other) const -> bool; METHOD octet (int n) const -> unsigned char; METHOD set_octet (int n, unsigned char oct) -> void; METHOD to_string (WithPort withport = IP_NO_PORT) const -> String; METHOD to_sockaddr_in() const -> sockaddr_in; METHOD operator< (const IPAddress& other) const -> bool; inline METHOD operator== (const IPAddress& other) const -> bool; inline METHOD operator!= (const IPAddress& other) const -> bool; inline METHOD operator[] (int n) const -> unsigned char; static METHOD from_string (String input, bool* ok = &sink) -> IPAddress; static METHOD resolve (String node, bool* ok = &sink) -> IPAddress; }; extern const IPAddress localhost; inline METHOD IPAddress::operator[] (int n) const -> unsigned char { return octet (n); } inline METHOD IPAddress::operator== (const IPAddress& other) const -> bool { return compare (other); } inline METHOD IPAddress::operator!= (const IPAddress& other) const -> bool { return not operator== (other); }