Wizard
Software Engineering Project - Wizard
|
#include <acceptor.h>
Public Member Functions | |
acceptor () | |
acceptor (socket_t handle) | |
acceptor (const sock_address &addr, int queSize=DFLT_QUE_SIZE) | |
acceptor (acceptor &&acc) | |
acceptor & | operator= (acceptor &&rhs) |
bool | listen (int queSize=DFLT_QUE_SIZE) |
bool | open (const sock_address &addr, int queSize=DFLT_QUE_SIZE, bool reuseSock=true) |
stream_socket | accept (sock_address *clientAddr=nullptr) |
![]() | |
socket () | |
socket (socket_t h) | |
socket (socket &&sock) noexcept | |
virtual | ~socket () |
bool | is_open () const |
bool | operator! () const |
operator bool () const | |
socket_t | handle () const |
virtual sa_family_t | family () const |
socket | clone () const |
void | clear (int val=0) |
socket_t | release () |
void | reset (socket_t h=INVALID_SOCKET) |
socket & | operator= (socket &&sock) noexcept |
bool | bind (const sock_address &addr) |
sock_address_any | address () const |
sock_address_any | peer_address () const |
bool | get_option (int level, int optname, void *optval, socklen_t *optlen) const |
template<typename T > | |
bool | get_option (int level, int optname, T *val) const |
bool | set_option (int level, int optname, const void *optval, socklen_t optlen) |
template<typename T > | |
bool | set_option (int level, int optname, const T &val) |
bool | set_non_blocking (bool on=true) |
int | last_error () const |
std::string | last_error_str () const |
bool | shutdown (int how=SHUT_RDWR) |
bool | close () |
Static Public Member Functions | |
static acceptor | create (int domain) |
![]() | |
static void | initialize () |
static void | destroy () |
static socket | create (int domain, int type, int protocol=0) |
static std::tuple< socket, socket > | pair (int domain, int type, int protocol=0) |
static std::string | error_str (int errNum) |
Static Protected Member Functions | |
static socket_t | create_handle (int domain) |
![]() | |
static int | get_last_error () |
Static Protected Attributes | |
static const int | DFLT_QUE_SIZE = 4 |
Additional Inherited Members | |
![]() | |
bool | close_on_err () |
void | set_last_error () |
template<typename T > | |
T | check_ret (T ret) const |
template<typename T > | |
bool | check_ret_bool (T ret) const |
socket_t | check_socket (socket_t ret) const |
bool | check_socket_bool (socket_t ret) const |
Class for creating a streaming server. Objects of this class bind and read_message on streaming ports for incoming connections. Normally, a server thread creates one of these and blocks on the call to accept incoming connections. The call to accept creates and returns a stream_socket which can then be used for the actual communications.
|
inline |
Creates an unconnected acceptor.
|
inlineexplicit |
Creates an acceptor from an existing OS socket handle and claims ownership of the handle.
handle | A socket handle from the operating system. |
|
inline |
Creates an acceptor socket and starts it listening to the specified address.
addr | The address to which this server should be bound. |
queSize | The listener queue size. |
|
inline |
Move constructor. Creates an acceptor by moving the other acceptor to this one.
acc | Another acceptor |
stream_socket sockpp::acceptor::accept | ( | sock_address * | clientAddr = nullptr | ) |
Accepts an incoming TCP connection and gets the address of the client.
clientAddr | Pointer to the variable that will get the address of a client when it connects. |
|
static |
Creates an unbound acceptor socket with an open OS socket handle. An application would need to manually bind and read_message to this acceptor to get incoming connections.
domain | The communications domain (address family). |
|
inlinestaticprotected |
Creates an underlying acceptor socket. The acceptor uses a stream socket type, but for our purposes is not classified (derived from) a streaming socket, since it doesn't support read and write to the socket.
domain | The communications domain (address family). |
|
inline |
Sets the socket listening on the address to which it is bound.
queSize | The listener queue size. |
bool sockpp::acceptor::open | ( | const sock_address & | addr, |
int | queSize = DFLT_QUE_SIZE, | ||
bool | reuseSock = true ) |
Opens the acceptor socket, binds it to the specified address, and starts listening.
addr | The address to which this server should be bound. |
queSize | The listener queue size. |
reuseSock | Whether the SO_REUSEPORT (or SO_REUSEADDR on Win32) socket option should be used before binding and listening. |
Move assignment.
rhs | The other socket to move into this one. |
|
staticprotected |
The default listener queue size.