45 std::vector<Item> new_list ;
46 loadImp( m_es , new_list ) ;
49 swap( m_list , new_list ) ;
67 std::vector<GNet::Address> result ;
68 addresses( result , name , port , af ) ;
78 std::size_t count = 0U ;
79 for(
const auto & item : m_list )
81 if( !name.empty() && ( item.name == name || item.altname == name ) && item.up && item.valid_address )
83 if( af == AF_UNSPEC ||
84 ( af == AF_INET6 && item.address.is6() ) ||
85 ( af == AF_INET && item.address.is4() ) )
88 out.push_back( item.address ) ;
89 out.back().setPort( port ) ;
100 for(
const auto & iface : *
this )
102 if( all || iface.up )
103 list.push_back( iface.name ) ;
105 std::sort( list.begin() , list.end() ) ;
106 list.erase( std::unique(list.begin(),list.end()) , list.end() ) ;
113 return m_list.begin() ;
118 return m_list.end() ;
121void GNet::Interfaces::readEvent()
125 std::string s = m_notifier->readEvent() ;
126 if( m_handler && !s.empty() )
127 m_handler->onInterfaceEvent( s ) ;
131void GNet::Interfaces::onFutureEvent()
135 std::string s = m_notifier->onFutureEvent() ;
136 if( m_handler && !s.empty() )
137 m_handler->onInterfaceEvent( s ) ;
143GNet::Interfaces::Item::Item() :
144 address(Address::defaultAddress())
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
An interface for receiving notification of network changes.
A class for getting a list of network interfaces and their addresses.
Interfaces(EventState)
Constructor resulting in an empty list.
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.
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.