43 std::vector<Item> new_list ;
44 loadImp( m_es , new_list ) ;
47 swap( m_list , new_list ) ;
65 std::vector<GNet::Address> result ;
66 addresses( result , name , port , af ) ;
76 std::size_t count = 0U ;
77 for(
const auto & item : m_list )
79 if( !name.empty() && ( item.name == name || item.altname == name ) && item.up && item.valid_address )
81 if( af == AF_UNSPEC ||
82 ( af == AF_INET6 && item.address.is6() ) ||
83 ( af == AF_INET && item.address.is4() ) )
86 out.push_back( item.address ) ;
87 out.back().setPort( port ) ;
98 for(
const auto & iface : *
this )
100 if( all || iface.up )
101 list.push_back( iface.name ) ;
103 std::sort( list.begin() , list.end() ) ;
104 list.erase( std::unique(list.begin(),list.end()) , list.end() ) ;
111 return m_list.begin() ;
116 return m_list.end() ;
119void GNet::Interfaces::readEvent()
123 std::string s = m_notifier->readEvent() ;
124 if( m_handler && !s.empty() )
125 m_handler->onInterfaceEvent( s ) ;
129void GNet::Interfaces::onFutureEvent()
133 std::string s = m_notifier->onFutureEvent() ;
134 if( m_handler && !s.empty() )
135 m_handler->onInterfaceEvent( s ) ;
141GNet::Interfaces::Item::Item() :
142 address(Address::defaultAddress())
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
An interface for receiving notification of network changes.
A class for getting a list of network interfaces and their addresses.
std::vector< Address > addresses(const std::string &name, unsigned int port, int af=AF_UNSPEC) const
Returns addresses bound to the given interface.
void load()
Loads or reloads the list.
Interfaces()
Default constructor resulting in an empty list.
bool loaded() const
Returns true if load()ed.
~Interfaces() override
Destructor.
static bool supported()
Returns false if a stubbed-out implementation.
const_iterator begin() const
Returns a begin iterator.
const_iterator end() const
Returns a one-off-the-end iterator.
G::StringArray names(bool all=false) const
Returns the interface names, optionally including interfaces that are not up.
std::vector< std::string > StringArray
A std::vector of std::strings.