1 #ifndef LIBSOCKET_DGRAMOVERSTREAM_H_7854202d13e741e98bb3b084eb3d6bc0
2 #define LIBSOCKET_DGRAMOVERSTREAM_H_7854202d13e741e98bb3b084eb3d6bc0
13 #include <netinet/ip.h>
14 #include <netinet/tcp.h>
89 ssize_t
sndmsg(
const void* buf,
size_t len);
90 ssize_t
rcvmsg(
void* dst,
size_t len);
92 ssize_t
sndmsg(
const std::string& msg);
93 ssize_t
rcvmsg(std::string* dst);
95 ssize_t
sndmsg(
const std::vector<uint8_t>& msg);
96 ssize_t
rcvmsg(std::vector<uint8_t>* dst);
99 static const size_t RECV_BUF_SIZE = 256;
102 std::unique_ptr<stream_client_socket> inner;
103 char prefix_buffer[FRAMING_PREFIX_LENGTH];
104 char RECV_BUF[RECV_BUF_SIZE];
106 ssize_t receive_bytes(
size_t);
Wraps a stream socket and provides a message-based API on top of it.
ssize_t rcvmsg(void *dst, size_t len)
Receive a message and store the first len bytes into buf.
uint32_t receive_header(void)
Receive and decode length header.
void enable_nagle(bool enable) const
Set TCP_NODELAY to !enabled on the underlying socket.
ssize_t sndmsg(const void *buf, size_t len)
Send the message in buf with length len as one frame.
Generic socket for active stream sockets (TCP client sockets, UNIX Stream clients)
Declarations of framing functions.
Contains libsocket elements.