15 #include <event2/listener.h> 53 virtual void Close(
void)
override;
95 static void Callback(evconnlistener * a_Listener, evutil_socket_t a_Socket, sockaddr * a_Addr,
int a_Len,
void * a_Self);
cTCPLinkImplPtrs m_Connections
Container for all currently active connections on this server.
virtual ~cServerHandleImpl() override
Closes the server, dropping all the connections.
std::vector< cServerHandleImplPtr > cServerHandleImplPtrs
virtual bool IsListening(void) const override
Returns true if the server has been started correctly and is currently listening for incoming connect...
int m_ErrorCode
Contains the error code for the failure to listen.
cServerHandleImpl(cNetwork::cListenCallbacksPtr a_ListenCallbacks)
Creates a new instance with the specified callbacks.
Interface that provides the methods available on a listening server socket.
static cServerHandleImplPtr Listen(UInt16 a_Port, cNetwork::cListenCallbacksPtr a_ListenCallbacks)
Creates a new server instance listening on the specified port.
cServerHandleImplPtr m_SelfPtr
The SharedPtr to self, so that it can be passed to created links.
evconnlistener * m_ConnListener
The LibEvent handle representing the main listening socket.
static void Callback(evconnlistener *a_Listener, evutil_socket_t a_Socket, sockaddr *a_Addr, int a_Len, void *a_Self)
The callback called by LibEvent upon incoming connection.
std::shared_ptr< cTCPLinkImpl > cTCPLinkImplPtr
void RemoveLink(const cTCPLinkImpl *a_Link)
Removes the specified link from m_Connections.
virtual void Close(void) override
Stops the server, no more incoming connections will be accepted.
std::shared_ptr< cServerHandleImpl > cServerHandleImplPtr
cNetwork::cListenCallbacksPtr m_ListenCallbacks
The callbacks used to notify about incoming connections.
std::vector< cTCPLinkImplPtr > cTCPLinkImplPtrs
bool m_IsListening
Set to true when the server is initialized successfully and is listening for incoming connections...
evconnlistener * m_SecondaryConnListener
The LibEvent handle representing the secondary listening socket (only when side-by-side listening is ...
cCriticalSection m_CS
Mutex protecting m_Connections againt multithreaded access.
AString m_ErrorMsg
Contains the error message for the failure to listen.
std::shared_ptr< cListenCallbacks > cListenCallbacksPtr