32 G_ASSERT( ! address_list.empty() ) ;
33 init( address_list ) ;
48 G_ASSERT( ! address_list.empty() ) ;
49 for( AddressList::const_iterator p = address_list.begin() ; p != address_list.end() ; ++p )
60 m_server_list.back().swap( ptr ) ;
65 for( AddressList::const_iterator p = address_list.begin() ; p != address_list.end() ; ++p )
76 result.reserve( 1U ) ;
77 result.push_back( address ) ;
86 result.reserve( 2U ) ;
93 for( AddressList::iterator p = result.begin() ; p != result.end() ; ++p )
94 (*p).setPort( port ) ;
104 result.reserve( 2U ) ;
110 result.reserve( list.size() ) ;
111 for( G::StringArray::const_iterator p = list.begin() ; p != list.end() ; ++p )
113 const bool is_inaddrany = (*p).empty() ;
121 result.push_back(
Address(*p,port) ) ;
130 for( List::iterator p = m_server_list.begin() ; p != m_server_list.end() ; ++p )
134 (*p).get()->cleanup() ;
144 for( List::const_iterator p = m_server_list.begin() ; p != m_server_list.end() ; ++p )
146 const Server & server = *((*p).get()) ;
147 G_LOG_S(
"GNet::MultiServer: " << type <<
" server on " << server.
address().second.displayString() ) ;
154 for( List::const_iterator p = m_server_list.begin() ; p != m_server_list.end() ; ++p )
156 if( (*p).get()->address().first )
158 result.first = true ;
159 result.second = (*p).get()->address().second ;
178 return m_ms.newPeer( peer_info , server_info ) ;
210 std::swap( other.m_p , m_p ) ;
225 GNet::MultiServer::ServerInfo::ServerInfo() :
226 m_address(
Address::defaultAddress())
static AddressList addressList(const Address &)
A trivial convenience fuction that returns the given address as a single-element list.
An abstract base class for the GNet::Server's connection to a remote client.
static bool canBind(const Address &listening_address, bool do_throw)
Checks that the specified address can be bound.
A private implementation class used by GNet::MultiServer.
void swap(MultiServerPtr &)
Swaps internals with the other.
MultiServerImp * get()
Returns the raw pointer.
The GNet::Address class encapsulates a TCP/UDP transport address.
std::vector< std::string > StringArray
A std::vector of std::strings.
MultiServerImp(MultiServer &, ExceptionHandler &, const Address &)
Constructor.
A network server class which listens on a specific port and spins off ServerPeer objects for each inc...
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
static bool canBind(const AddressList &listening_address_list, bool do_throw)
Checks that the specified addresses can be bound.
static Address defaultAddress()
Returns a default address, being the IPv4 wildcard address with a zero port number.
void cleanup()
Does cleanup.
A structure used in GNet::MultiServer::newPeer().
virtual ~MultiServer()
Destructor.
A private implementation class used by GNet::MultiServer.
MultiServerPtr(ServerImp *=nullptr)
Constructor.
void init(const AddressList &address_list)
Initilisation after default construction.
void serverCleanup()
Should be called from all derived classes' destructors so that peer objects can use their Server obje...
~MultiServerPtr()
Destructor.
A server that listens on more than one interface using a facade pattern to multiple GNet::Server inst...
Address m_address
The server address that the peer connected to.
std::pair< bool, Address > firstAddress() const
Returns the first listening address.
MultiServer(ExceptionHandler &, const AddressList &address_list)
Constructor.
static bool supports(Family)
Returns true if the implementation supports the given address family.
std::pair< bool, Address > address() const
Returns the listening address.
void serverReport(const std::string &server_type) const
Writes to the system log a summary of the underlying server objects and their addresses.
void operator=(const MultiServerPtr &)
Assignment operator.