lib45d
45Drives C++ Library API Documentation
|
Base Unix Socket Class for opening and closing the socket. More...
#include <45d/socket/SocketBase.hpp>
Public Member Functions | |
SocketBase (int domain, int type, int protocol=0) | |
Construct a new Socket Base object. Opens a socket fd. More... | |
~SocketBase () | |
Destroy the Socket Base object. Calls close() on the socket fd. More... | |
void | close_connection (int fd=0) |
Close a connection. More... | |
void | send_data_async (const std::string &str, int flags=0, int fd=0) |
Send a string. More... | |
void | send_data_sync (const std::string &str, int flags=0, int fd=0) |
Send a string and wait for ACK. More... | |
void | send_data (const std::string &str, int flags=0, int fd=0) |
Send a string and wait for ACK (alias for ffd::SocketBase::send_data_sync(const std::string&, int, int)) More... | |
void | send_data_async (const std::vector< std::string > &vec, int flags=0, int fd=0) |
Send a vector as a record separator (0x1E) delimited string. More... | |
void | send_data_sync (const std::vector< std::string > &vec, int flags=0, int fd=0) |
Send a vector as a record separator (0x1E) delimited string and wait for ACK. More... | |
void | send_data (const std::vector< std::string > &vec, int flags=0, int fd=0) |
Send a vector as a record separator (0x1E) delimited string and wait for ACK (alias for ffd::SocketBase::send_data_sync(const std::vector<std::string>&, int, int)) More... | |
void | receive_data_async (std::string &payload, int flags=0, int fd=0) |
Receive a string. More... | |
void | receive_data_sync (std::string &payload, int flags=0, int fd=0) |
Receive a string and reply with ACK. More... | |
void | receive_data (std::string &payload, int flags=0, int fd=0) |
Receive a string and reply with ACK (alias for ffd::SocketBase::receive_data_sync(std::string&, int, int)) More... | |
void | receive_data_async (std::vector< std::string > &vec, int flags=0, int fd=0) |
Receive a vector as a record separator (0x1E) delimited string. More... | |
void | receive_data_sync (std::vector< std::string > &vec, int flags=0, int fd=0) |
Receive a vector as a record separator (0x1E) delimited string and reply with ACK. More... | |
void | receive_data (std::vector< std::string > &vec, int flags=0, int fd=0) |
Receive a vector as a record separator (0x1E) delimited string and reply with ACK (alias for ffd::SocketBase::receive_data_sync(std::vector<std::string>&, int, int)) More... | |
void | shutdown (int how=SHUT_RDWR) |
Call shutdown() on the socket fd, waking any blocked threads. More... | |
Protected Attributes | |
int | fd_ |
File descriptor of socket. | |
int | io_fd_ |
Connection fd. | |
char | ACK |
char to send for acknowledging reception | |
Base Unix Socket Class for opening and closing the socket.
|
inline |
Construct a new Socket Base object. Opens a socket fd.
see man socket(2) for details
domain | Usually AF_UNIX or AF_INET |
type | Usually SOCK_STREAM |
protocol | Normally just 0 |
|
inline |
Destroy the Socket Base object. Calls close() on the socket fd.
|
inline |
Close a connection.
fd | Socket connection fd or default for internal io_fd_ |
|
inline |
Receive a string and reply with ACK (alias for ffd::SocketBase::receive_data_sync(std::string&, int, int))
payload | Received message returned by reference |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Receive a vector as a record separator (0x1E) delimited string and reply with ACK (alias for ffd::SocketBase::receive_data_sync(std::vector<std::string>&, int, int))
vec | Received vector returned by reference |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Receive a string.
payload | Received message returned by reference |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Receive a vector as a record separator (0x1E) delimited string.
vec | Received vector returned by reference |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Receive a string and reply with ACK.
payload | Received message returned by reference |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Receive a vector as a record separator (0x1E) delimited string and reply with ACK.
vec | Received vector returned by reference |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Send a string and wait for ACK (alias for ffd::SocketBase::send_data_sync(const std::string&, int, int))
str | Message to send |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Send a vector as a record separator (0x1E) delimited string and wait for ACK (alias for ffd::SocketBase::send_data_sync(const std::vector<std::string>&, int, int))
vec | Vector to send |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Send a string.
str | Message to send |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Send a vector as a record separator (0x1E) delimited string.
vec | Vector to send |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Send a string and wait for ACK.
str | Message to send |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Send a vector as a record separator (0x1E) delimited string and wait for ACK.
vec | Vector to send |
flags | see man send(2) |
fd | Optional file descriptor for connection |
|
inline |
Call shutdown() on the socket fd, waking any blocked threads.
how | Either SHUT_RD, SHUT_WR, or SHUT_RDWR |