E-MailRelay
|
A class for getting a list of network interfaces and their addresses. More...
#include <ginterfaces.h>
Classes | |
struct | Item |
Used by GNet::Interfaces to describe an interface address binding. More... | |
Public Types | |
using | const_iterator = std::vector< Item >::const_iterator |
![]() | |
enum class | Reason { failed , closed , down , reset , abort , other } |
Public Member Functions | |
Interfaces (EventState) | |
Constructor resulting in an empty list. More... | |
Interfaces (EventState, InterfacesHandler &) | |
Constructor resulting in an empty list with an attached event handler. More... | |
~Interfaces () override | |
Destructor. | |
void | load () |
Loads or reloads the list. More... | |
bool | loaded () const |
Returns true if load()ed. More... | |
G::StringArray | names (bool all=false) const |
Returns the interface names, optionally including interfaces that are not up. More... | |
const_iterator | begin () const |
Returns a begin iterator. More... | |
const_iterator | end () const |
Returns a one-off-the-end iterator. More... | |
std::vector< Address > | addresses (const std::string &name, unsigned int port, int af=AF_UNSPEC) const |
Returns addresses bound to the given interface. More... | |
std::size_t | addresses (std::vector< Address > &out, const std::string &name, unsigned int port, int af=AF_UNSPEC) const |
An overload that appends to the given list and returns the number added. More... | |
Interfaces (const Interfaces &)=delete | |
Interfaces (Interfaces &&)=delete | |
Interfaces | operator= (const Interfaces &)=delete |
Interfaces | operator= (Interfaces &&)=delete |
![]() | |
EventHandler () | |
Constructor. | |
virtual | ~EventHandler () |
Destructor. More... | |
virtual void | readEvent () |
Called for a read event. More... | |
virtual void | writeEvent () |
Called for a write event. More... | |
virtual void | otherEvent (Reason) |
Called for a socket-exception event, or a socket-close event on windows. More... | |
void | setDescriptor (Descriptor) noexcept |
File descriptor setter. Used by the event loop. More... | |
Descriptor | descriptor () const noexcept |
File descriptor getter. Used by the event loop. More... | |
EventHandler (const EventHandler &)=delete | |
EventHandler (EventHandler &&)=delete | |
EventHandler & | operator= (const EventHandler &)=delete |
EventHandler & | operator= (EventHandler &&)=delete |
![]() | |
virtual | ~FutureEventHandler ()=default |
Destructor. | |
virtual void | onFutureEvent ()=0 |
Callback function that delivers the future event. | |
Static Public Member Functions | |
static bool | supported () |
Returns false if a stubbed-out implementation. More... | |
static bool | active () |
Returns true if the implementation can raise InterfacesHandler events. More... | |
![]() | |
static std::string | str (Reason) |
Returns a printable description of the other-event reason. More... | |
A class for getting a list of network interfaces and their addresses.
An InterfacesHandler interface can be supplied to the constructor in order to get dynamic updates.
Definition at line 47 of file ginterfaces.h.
using GNet::Interfaces::const_iterator = std::vector<Item>::const_iterator |
Definition at line 64 of file ginterfaces.h.
|
explicit |
Constructor resulting in an empty list.
Use load() to initialise.
Definition at line 28 of file ginterfaces_common.cpp.
GNet::Interfaces::Interfaces | ( | EventState | es, |
InterfacesHandler & | handler | ||
) |
Constructor resulting in an empty list with an attached event handler.
Use load() or addresses() to initialise the list and activate the event listener.
Definition at line 34 of file ginterfaces_common.cpp.
|
static |
Returns true if the implementation can raise InterfacesHandler events.
Definition at line 44 of file ginterfaces_none.cpp.
std::vector< GNet::Address > GNet::Interfaces::addresses | ( | const std::string & | name, |
unsigned int | port, | ||
int | af = AF_UNSPEC |
||
) | const |
Returns addresses bound to the given interface.
Does a lazy load().
Definition at line 65 of file ginterfaces_common.cpp.
std::size_t GNet::Interfaces::addresses | ( | std::vector< Address > & | out, |
const std::string & | name, | ||
unsigned int | port, | ||
int | af = AF_UNSPEC |
||
) | const |
An overload that appends to the given list and returns the number added.
Definition at line 73 of file ginterfaces_common.cpp.
GNet::Interfaces::const_iterator GNet::Interfaces::begin | ( | ) | const |
Returns a begin iterator.
Definition at line 111 of file ginterfaces_common.cpp.
GNet::Interfaces::const_iterator GNet::Interfaces::end | ( | ) | const |
Returns a one-off-the-end iterator.
Definition at line 116 of file ginterfaces_common.cpp.
void GNet::Interfaces::load | ( | ) |
Loads or reloads the list.
Definition at line 43 of file ginterfaces_common.cpp.
bool GNet::Interfaces::loaded | ( | ) | const |
Returns true if load()ed.
Definition at line 59 of file ginterfaces_common.cpp.
G::StringArray GNet::Interfaces::names | ( | bool | all = false | ) | const |
Returns the interface names, optionally including interfaces that are not up.
Definition at line 97 of file ginterfaces_common.cpp.
|
static |
Returns false if a stubbed-out implementation.
Definition at line 53 of file ginterfaces_common.cpp.