HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NET_SocketListener< AcceptorT, SocketT > Class Template Referenceabstract

#include <NET_SocketListener.h>

+ Inheritance diagram for NET_SocketListener< AcceptorT, SocketT >:

Classes

struct  Empty
 
struct  PortInfo
 

Public Types

using acceptor_type = AcceptorT
 
using socket_type = SocketT
 
using endpoint_type = typename AcceptorT::endpoint_type
 

Public Member Functions

template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void start (int initial_port, int max_port_range=-1, bool use_system_port=false, const ASIO_IPAddress &address=ASIO_IPAddressV4())
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void start ()
 
void start (const ASIO_TCPEndpoint &ep)
 
void close (bool force) override
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
int port () const
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void setPort (int port)
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void setMaxPort (int port)
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void setUseSystemPort (bool use_sys)
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void setUseIPv6 (bool use_v6)
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
bool useIPv6 () const
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void setBindAddress (const ASIO_IPAddress &bind_address)
 
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
const ASIO_IPAddressbindAddress () const
 
endpoint_type endpoint () const
 
bool isOpen () const override
 
- Public Member Functions inherited from NET_ISocketListener
virtual ~NET_ISocketListener ()=default
 

Protected Member Functions

 NET_SocketListener (ASIO_IOContext &ctx)
 
 NET_SocketListener (const ASIO_IOContext::executor_type &executor)
 
virtual void init_ ()
 
virtual void onAccept_ (const hboost::system::error_code &ec, socket_type socket)=0
 
void startAccept_ ()
 Start an async accept. If the accept was a success onAccept_ is called. More...
 
- Protected Member Functions inherited from NET_ISocketListener
 NET_ISocketListener (ASIO_IOContext &ctx)
 
 NET_ISocketListener (const ASIO_IOContext::executor_type &executor)
 
void fail (const hboost::system::error_code &ec, const char *what)
 Called when something failed with the socket listener. More...
 

Protected Attributes

AcceptorT myAcceptor
 
std::conditional_t
< socket_info< socket_type >
::uses_port, PortInfo, Empty
myPortInfo
 
- Protected Attributes inherited from NET_ISocketListener
NET_ISocketGroupmySocketGroup
 
ASIO_IOContext::executor_type myExecutor
 
NET_ConnectionManager myConnectionManager
 

Detailed Description

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
class NET_SocketListener< AcceptorT, SocketT >

Definition at line 83 of file NET_SocketListener.h.

Member Typedef Documentation

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
using NET_SocketListener< AcceptorT, SocketT >::acceptor_type = AcceptorT

Definition at line 86 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
using NET_SocketListener< AcceptorT, SocketT >::endpoint_type = typename AcceptorT::endpoint_type

Definition at line 88 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
using NET_SocketListener< AcceptorT, SocketT >::socket_type = SocketT

Definition at line 87 of file NET_SocketListener.h.

Constructor & Destructor Documentation

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
NET_SocketListener< AcceptorT, SocketT >::NET_SocketListener ( ASIO_IOContext ctx)
inlineprotected

Definition at line 224 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
NET_SocketListener< AcceptorT, SocketT >::NET_SocketListener ( const ASIO_IOContext::executor_type &  executor)
inlineprotected

Definition at line 227 of file NET_SocketListener.h.

Member Function Documentation

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
const ASIO_IPAddress& NET_SocketListener< AcceptorT, SocketT >::bindAddress ( ) const
inline

Definition at line 214 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
void NET_SocketListener< AcceptorT, SocketT >::close ( bool  force)
inlineoverridevirtual

Implements NET_ISocketListener.

Definition at line 137 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
endpoint_type NET_SocketListener< AcceptorT, SocketT >::endpoint ( ) const
inline

Definition at line 219 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
virtual void NET_SocketListener< AcceptorT, SocketT >::init_ ( )
inlineprotectedvirtual

Do any initialization after the socket listener has been setup but before we actually start accepting requests.

Definition at line 235 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
bool NET_SocketListener< AcceptorT, SocketT >::isOpen ( ) const
inlineoverridevirtual

Implements NET_ISocketListener.

Definition at line 221 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
virtual void NET_SocketListener< AcceptorT, SocketT >::onAccept_ ( const hboost::system::error_code &  ec,
socket_type  socket 
)
protectedpure virtual

Called each time a new socket is accepted. Make sure to add the connection handler to the connection manager so that we can easily stop all requests that came from this listening socket when shutting down.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
int NET_SocketListener< AcceptorT, SocketT >::port ( ) const
inline

Returns the port the socket listener is bound to. It does not return the port that was requested to bind to.

Definition at line 165 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void NET_SocketListener< AcceptorT, SocketT >::setBindAddress ( const ASIO_IPAddress bind_address)
inline

Definition at line 207 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void NET_SocketListener< AcceptorT, SocketT >::setMaxPort ( int  port)
inline

Definition at line 179 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void NET_SocketListener< AcceptorT, SocketT >::setPort ( int  port)
inline

Definition at line 172 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void NET_SocketListener< AcceptorT, SocketT >::setUseIPv6 ( bool  use_v6)
inline

Definition at line 193 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void NET_SocketListener< AcceptorT, SocketT >::setUseSystemPort ( bool  use_sys)
inline

Definition at line 186 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
void NET_SocketListener< AcceptorT, SocketT >::start ( int  initial_port,
int  max_port_range = -1,
bool  use_system_port = false,
const ASIO_IPAddress address = ASIO_IPAddressV4() 
)
inline

Definition at line 93 of file NET_SocketListener.h.

template<typename AcceptorT , typename SocketT >
template<typename S , typename Detected >
void NET_SocketListener< AcceptorT, SocketT >::start ( )

Definition at line 268 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
void NET_SocketListener< AcceptorT, SocketT >::start ( const ASIO_TCPEndpoint ep)
inline

Definition at line 110 of file NET_SocketListener.h.

template<typename AcceptorT , typename SocketT >
void NET_SocketListener< AcceptorT, SocketT >::startAccept_ ( )
protected

Start an async accept. If the accept was a success onAccept_ is called.

Definition at line 302 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
template<typename S = SocketT, typename = typename std::enable_if_t<socket_info<S>::uses_port>>
bool NET_SocketListener< AcceptorT, SocketT >::useIPv6 ( ) const
inline

Definition at line 200 of file NET_SocketListener.h.

Member Data Documentation

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
AcceptorT NET_SocketListener< AcceptorT, SocketT >::myAcceptor
protected

Definition at line 248 of file NET_SocketListener.h.

template<typename AcceptorT, typename SocketT = hboost::asio::basic_stream_socket<typename AcceptorT::protocol_type>>
std::conditional_t<socket_info<socket_type>::uses_port, PortInfo, Empty> NET_SocketListener< AcceptorT, SocketT >::myPortInfo
protected

Definition at line 262 of file NET_SocketListener.h.


The documentation for this class was generated from the following file: