Wizard
Software Engineering Project - Wizard
|
#include <datagram_socket.h>
Public Types | |
using | addr_t = ADDR |
Public Member Functions | |
datagram_socket_tmpl () | |
datagram_socket_tmpl (socket_t handle) | |
datagram_socket_tmpl (const ADDR &addr) | |
datagram_socket_tmpl (datagram_socket_tmpl &&other) | |
datagram_socket_tmpl & | operator= (datagram_socket_tmpl &&rhs) |
bool | bind (const ADDR &addr) |
bool | connect (const ADDR &addr) |
ssize_t | send_to (const void *buf, size_t n, int flags, const ADDR &addr) |
ssize_t | send_to (const std::string &s, int flags, const ADDR &addr) |
ssize_t | send_to (const void *buf, size_t n, const ADDR &addr) |
ssize_t | send_to (const std::string &s, const ADDR &addr) |
ssize_t | recv_from (void *buf, size_t n, int flags, ADDR *srcAddr) |
ssize_t | recv_from (void *buf, size_t n, ADDR *srcAddr=nullptr) |
![]() | |
datagram_socket () | |
datagram_socket (socket_t handle) | |
datagram_socket (const sock_address &addr) | |
datagram_socket (datagram_socket &&other) | |
datagram_socket & | operator= (datagram_socket &&rhs) |
bool | connect (const sock_address &addr) |
ssize_t | send_to (const void *buf, size_t n, int flags, const sock_address &addr) |
ssize_t | send_to (const std::string &s, int flags, const sock_address &addr) |
ssize_t | send_to (const void *buf, size_t n, const sock_address &addr) |
ssize_t | send_to (const std::string &s, const sock_address &addr) |
ssize_t | send (const void *buf, size_t n, int flags=0) |
ssize_t | send (const std::string &s, int flags=0) |
ssize_t | recv_from (void *buf, size_t n, int flags, sock_address *srcAddr=nullptr) |
ssize_t | recv_from (void *buf, size_t n, sock_address *srcAddr=nullptr) |
ssize_t | recv (void *buf, size_t n, int flags=0) |
![]() | |
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 std::tuple< datagram_socket_tmpl, datagram_socket_tmpl > | pair (int protocol=0) |
![]() | |
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 Public Attributes | |
static constexpr sa_family_t | ADDRESS_FAMILY = ADDR::ADDRESS_FAMILY |
![]() | |
static constexpr int | COMM_TYPE = SOCK_DGRAM |
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 |
![]() | |
static socket_t | create_handle (int domain) |
![]() | |
static int | get_last_error () |
Base class for datagram sockets.
Datagram sockets are normally connectionless, where each packet is individually routed and delivered.
using sockpp::datagram_socket_tmpl< ADDR >::addr_t = ADDR |
The type of address for the socket.
|
inline |
Creates an unbound datagram socket. This can be used as a client or later bound as a server socket.
|
inline |
Creates a datagram socket from an existing OS socket handle and claims ownership of the handle.
handle | A socket handle from the operating system. |
|
inline |
Creates a UDP socket and binds it to the address.
addr | The address to bind. |
|
inline |
Move constructor.
other | The other socket to move to this one |
|
inline |
Binds the socket to the local address. Datagram sockets can bind to a local address/adapter to filter which incoming packets to receive.
addr | The address on which to bind. |
|
inline |
Connects the socket to the remote address. In the case of datagram sockets, this does not create an actual connection, but rather specifies the address to which datagrams are sent by default and the only address from which packets are received.
addr | The address on which to "connect". |
|
inline |
Move assignment.
rhs | The other socket to move into this one. |
|
inlinestatic |
Creates a pair of connected stream sockets.
Whether this will work at all is highly system and domain dependent. Currently it is only known to work for Unix-domain sockets on *nix systems.
protocol | The protocol to be used with the socket. (Normally 0) |
|
inline |
Receives a message on the socket.
buf | Buffer to get the incoming data. |
n | The number of bytes to read. |
srcAddr | Receives the address of the peer that sent the message |
|
inline |
Receives a message on the socket.
buf | Buffer to get the incoming data. |
n | The number of bytes to read. |
flags | The option bit flags. See send(2). |
srcAddr | Receives the address of the peer that sent the message |
|
inline |
Sends a string to another socket.
s | The string to send. |
addr | The remote destination of the data. |
|
inline |
Sends a string to the socket at the specified address.
s | The string to send. |
flags | The flags. See send(2). |
addr | The remote destination of the data. |
|
inline |
Sends a message to another socket.
buf | The data to send. |
n | The number of bytes in the data buffer. |
addr | The remote destination of the data. |
|
inline |
Sends a message to the socket at the specified address.
buf | The data to send. |
n | The number of bytes in the data buffer. |
flags | The option bit flags. See send(2). |
addr | The remote destination of the data. |
|
staticconstexpr |
The address family for this type of address