|
| stream_socket_tmpl () |
| Creates an unconnected streaming socket.
|
|
| stream_socket_tmpl (socket_t handle) |
| Creates a streaming socket from an existing OS socket handle and claims ownership of the handle. More...
|
|
| stream_socket_tmpl (stream_socket &&sock) |
| Move constructor. More...
|
|
| stream_socket_tmpl (stream_socket_tmpl &&sock) |
| Creates a stream socket by copying the socket handle from the specified socket object and transfers ownership of the socket.
|
|
stream_socket_tmpl & | operator= (stream_socket_tmpl &&rhs) |
| Move assignment. More...
|
|
stream_socket_tmpl | create (int protocol=0) |
| Cretates a stream socket. More...
|
|
addr_t | address () const |
| Gets the local address to which the socket is bound. More...
|
|
addr_t | peer_address () const |
| Gets the address of the remote peer, if this socket is connected. More...
|
|
| stream_socket () |
| Creates an unconnected streaming socket.
|
|
| stream_socket (socket_t handle) |
| Creates a streaming socket from an existing OS socket handle and claims ownership of the handle. More...
|
|
| stream_socket (stream_socket &&sock) |
| Creates a stream socket by copying the socket handle from the specified socket object and transfers ownership of the socket.
|
|
stream_socket & | operator= (stream_socket &&rhs) |
| Move assignment. More...
|
|
stream_socket | clone () const |
| Creates a new stream_socket that refers to this one. More...
|
|
virtual ssize_t | read (void *buf, size_t n) |
| Reads from the port. More...
|
|
virtual ssize_t | read_n (void *buf, size_t n) |
| Best effort attempts to read the specified number of bytes. More...
|
|
ssize_t | read (const std::vector< iovec > &ranges) |
| Reads discontiguous memory ranges from the socket. More...
|
|
virtual bool | read_timeout (const std::chrono::microseconds &to) |
| Set a timeout for read operations. More...
|
|
template<class Rep , class Period > |
bool | read_timeout (const std::chrono::duration< Rep, Period > &to) |
| Set a timeout for read operations. More...
|
|
virtual ssize_t | write (const void *buf, size_t n) |
| Writes the buffer to the socket. More...
|
|
virtual ssize_t | write_n (const void *buf, size_t n) |
| Best effort attempt to write the whole buffer to the socket. More...
|
|
virtual ssize_t | write (const std::string &s) |
| Best effort attempt to write a string to the socket. More...
|
|
virtual ssize_t | write (const std::vector< iovec > &ranges) |
| Writes discontiguous memory ranges to the socket. More...
|
|
virtual bool | write_timeout (const std::chrono::microseconds &to) |
| Set a timeout for write operations. More...
|
|
template<class Rep , class Period > |
bool | write_timeout (const std::chrono::duration< Rep, Period > &to) |
| Set a timeout for write operations. More...
|
|
| socket () |
| Creates an unconnected (invalid) socket.
|
|
| socket (socket_t h) |
| Creates a socket from an existing OS socket handle. More...
|
|
| socket (socket &&sock) noexcept |
| Move constructor. More...
|
|
virtual | ~socket () |
| Destructor closes the socket.
|
|
bool | is_open () const |
| Determines if the socket is open (valid). More...
|
|
bool | operator! () const |
| Determines if the socket is closed or in an error state. More...
|
|
| operator bool () const |
| Determines if the socket is open and in an error-free state. More...
|
|
socket_t | handle () const |
| Get the underlying OS socket handle. More...
|
|
virtual sa_family_t | family () const |
| Gets the network family of the address to which the socket is bound. More...
|
|
socket | clone () const |
| Creates a new socket that refers to this one. More...
|
|
void | clear (int val=0) |
| Clears the error flag for the object. More...
|
|
socket_t | release () |
| Releases ownership of the underlying socket object. More...
|
|
void | reset (socket_t h=INVALID_SOCKET) |
| Replaces the underlying managed socket object. More...
|
|
socket & | operator= (socket &&sock) noexcept |
| Move assignment. More...
|
|
bool | bind (const sock_address &addr) |
| Binds the socket to the specified address. More...
|
|
sock_address_any | address () const |
| Gets the local address to which the socket is bound. More...
|
|
sock_address_any | peer_address () const |
| Gets the address of the remote peer, if this socket is connected. More...
|
|
bool | get_option (int level, int optname, void *optval, socklen_t *optlen) const |
| Gets the value of a socket option. More...
|
|
template<typename T > |
bool | get_option (int level, int optname, T *val) const |
| Gets the value of a socket option. More...
|
|
bool | set_option (int level, int optname, const void *optval, socklen_t optlen) |
| Sets the value of a socket option. More...
|
|
template<typename T > |
bool | set_option (int level, int optname, const T &val) |
| Sets the value of a socket option. More...
|
|
bool | set_non_blocking (bool on=true) |
| Places the socket into or out of non-blocking mode. More...
|
|
int | last_error () const |
| Gets the code for the last errror. More...
|
|
std::string | last_error_str () const |
| Gets a string describing the last errror. More...
|
|
bool | shutdown (int how=SHUT_RDWR) |
| Shuts down all or part of the full-duplex connection. More...
|
|
bool | close () |
| Closes the socket. More...
|
|
template<typename ADDR>
class sockpp::stream_socket_tmpl< ADDR >
Template for creating specific stream types (IPv4, IPv6, etc).
This just overrides methods that take a generic address and replace them with the address type for a specific family. This doesn't add any runtime functionality, but has compile-time checks that address types aren't accidentally being mixed for an object.