10#if __has_include("defs.h")
14#include "safe_winsock.h"
28 const std::string& proto = std::string ());
30 inaddr (
const sockaddr& adr);
34 operator sockaddr* ()
const
36 return (sockaddr*)&sa;
42 operator const sockaddr& ()
const
44 return *(sockaddr*)&sa;
50 return *(sockaddr*)&sa;
54 unsigned short port ()
const
56 return ntohs (sa.sin_port);
60 void port (
unsigned short p)
62 sa.sin_port = htons (p);
66 erc port (
const std::string& service,
const std::string& proto = std::string ());
71 return ntohl (sa.sin_addr.s_addr);
77 sa.sin_addr.s_addr = htonl (h);
85 const char*
ntoa ()
const;
90 return ((
host () & 0xf0000000) == 0xe0000000);
102 memcpy (&sa, &rhs.sa, sizeof (sa));
109 return (sa.sin_addr.S_un.S_addr == other.sa.sin_addr.S_un.S_addr)
110 && (sa.sin_port == other.sa.sin_port);
116 return (!
operator== (other));
124 strm << addr.
ntoa () <<
':' << addr.
port ();
objects returned as a function result or thrown directly.
Definition errorcode.h:68
sockaddr wrapper
Definition inaddr.h:23
static unsigned localhost()
Return local address in HOST order.
Definition inaddr.cpp:162
void host(unsigned int h)
set host address
Definition inaddr.h:75
std::string hostname() const
Find hostname from the host address in sockaddr.
Definition inaddr.cpp:139
void port(unsigned short p)
set port number
Definition inaddr.h:60
const char * ntoa() const
return host address in dotted format
Definition inaddr.cpp:198
unsigned short port() const
return port number in host order
Definition inaddr.h:54
unsigned host() const
return host address in host order
Definition inaddr.h:69
inaddr & operator=(const inaddr &rhs)
Assignment operator.
Definition inaddr.h:100
bool operator!=(const inaddr &other) const
Inequality operator.
Definition inaddr.h:114
bool is_multicast() const
check if it's multicast host
Definition inaddr.h:88
bool operator==(const inaddr &other) const
Equality operator.
Definition inaddr.h:107
Definition of erc and erfac classes.
std::ostream & operator<<(std::ostream &strm, const mlib::inaddr &addr)
Serialize an address as '<hostname>:<port>'.
Definition inaddr.h:122