|
TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
|
Lightweight wrapper around a connected socket file descriptor. More...
#include <tec_socket.hpp>
Public Member Functions | |
| Socket (int _fd, const char *_addr, int _port) | |
| Construct a Socket wrapper from an accepted or connected fd. | |
| Socket (int _fd, const char *_addr, int _port, char *_buffer, size_t _buffer_size) | |
| Construct a Socket wrapper from an accepted or connected fd. | |
Static Public Member Functions | |
| static Status | recv (Bytes &data, const Socket *sock, size_t length) |
| Receive data from a socket into a MemFile (Bytes). | |
| static Status | send (const Bytes &data, const Socket *sock) |
| Send the entire contents of a MemFile (Bytes) through a socket. | |
Public Attributes | |
| int | fd |
| Underlying socket file descriptor. | |
| char | addr [INET6_ADDRSTRLEN] |
| Peer address as a null-terminated string (IPv4 or IPv6). | |
| int | port |
| Peer port number. | |
| char * | buffer |
| Buffer used in send/recv operations. | |
| size_t | buffer_size |
| Size of the buffer. | |
Lightweight wrapper around a connected socket file descriptor.
Stores the file descriptor along with peer address and port for logging and diagnostic purposes.
Receive data from a socket into a MemFile (Bytes).
Reads until the requested length is received, or until a null terminator is detected when length == 0 (character stream mode).
| data | MemFile (Bytes) to append received data to. |
| sock | Pointer to the Socket instance. |
| length | Expected number of bytes (0 = read until null terminator). |