Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
Tcp Class Reference

General-purpose TCP socket wrapper with optional TLS support via mbedTLS (altcp). More...

#include <Tcp.h>

+ Collaboration diagram for Tcp:

Public Member Functions

 Tcp ()
 
 Tcp (int sockfd)
 For accepted sockets.
 
 ~Tcp ()
 
 Tcp (const Tcp &)=delete
 
Tcpoperator= (const Tcp &)=delete
 
 Tcp (Tcp &&other) noexcept
 
Tcpoperator= (Tcp &&other) noexcept
 
std::string getPeerIp () const
 
void setRootCACertificate (const std::string &pem)
 Set the Root CA certificate to be used for client TLS connections (PEM format).
 
void setServerTlsConfig (const std::string &certPem, const std::string &keyPem)
 Set the certificate and key to use for server-side TLS (PEM format).
 
bool connect (const char *host, int port, bool useTls=false)
 Connect to a remote host.
 
int send (const char *buffer, size_t size)
 Send data over the connection.
 
int recv (char *buffer, size_t size, uint32_t timeout_ms)
 Receive data from the connection.
 
int close ()
 Close the connection and free resources.
 
bool bindAndListen (int port)
 Bind and listen on a port for incoming connections (for server use).
 
bool bindAndListenPlain (int port)
 
bool bindAndListenTls (int port)
 
Tcpaccept ()
 Accept a new incoming connection (for server use).
 
bool isValid () const
 Check if the socket is valid.
 
bool isConnected () const
 Check if the socket is connected.
 
int getSocketFd () const
 Get the raw socket file descriptor (may be -1 for TLS-only connection).
 
void setHostname (const char *name)
 
const char * getHostname () const
 

Private Member Functions

bool connectPlain (const ip_addr_t &ip, int port)
 
bool connectTls (const ip_addr_t &ip, int port)
 

Static Private Member Functions

static err_t tlsRecvCallback (void *arg, struct altcp_pcb *conn, struct pbuf *p, err_t err)
 
static err_t acceptCallback (void *arg, struct altcp_pcb *new_conn, err_t err)
 

Private Attributes

int sockfd = -1
 
bool connected = false
 
bool use_tls = false
 
bool is_server_socket = false
 
int connectResult = ERR_OK
 
std::string root_ca_cert
 
struct pbuf * recv_buffer = nullptr
 Buffer for TLS receive.
 
size_t recv_offset = 0
 
std::string server_tls_cert
 
std::string server_tls_key
 
struct altcp_tls_config * server_tls_config = nullptr
 
TaskHandle_t connectingTask = nullptr
 Task handle for async operations.
 
TaskHandle_t waiting_task = nullptr
 Task handle for async operations.
 
altcp_pcb * pending_client = nullptr
 For TLS: set by acceptCallback.
 
char hostname [64] = {0}
 Hostname for TLS connections.
 

Static Private Attributes

static constexpr size_t MAX_TLS_SEGMENT_SIZE = 1460
 

Detailed Description

Definition at line 39 of file Tcp.h.

Constructor & Destructor Documentation

◆ Tcp() [1/4]

Tcp::Tcp ( )

Definition at line 24 of file Tcp.cpp.

25 : sockfd(-1), connected(false), use_tls(false)
26#if PICO_TCP_ENABLE_TLS
27 ,
28 tls_config(nullptr), server_tls_config(nullptr),
29 tls_pcb(nullptr)
30#endif
31{
32}
bool connected
Definition Tcp.h:143
int sockfd
Definition Tcp.h:142
bool use_tls
Definition Tcp.h:144
struct altcp_tls_config * server_tls_config
Definition Tcp.h:161

Referenced by accept().

+ Here is the caller graph for this function:

◆ Tcp() [2/4]

Tcp::Tcp ( int  sockfd)
explicit

Definition at line 34 of file Tcp.cpp.

35 : sockfd(fd), connected(true), use_tls(false)
36#if PICO_TCP_ENABLE_TLS
37 ,
38 tls_config(nullptr), server_tls_config(nullptr),
39 tls_pcb(nullptr)
40#endif
41{
42}

◆ ~Tcp()

Tcp::~Tcp ( )

Definition at line 44 of file Tcp.cpp.

45{
46 close();
47}
int close()
Close the connection and free resources.
Definition Tcp.cpp:443

References close().

+ Here is the call graph for this function:

◆ Tcp() [3/4]

Tcp::Tcp ( const Tcp )
delete

◆ Tcp() [4/4]

Tcp::Tcp ( Tcp &&  other)
noexcept

Definition at line 49 of file Tcp.cpp.

50{
51 *this = std::move(other);
52}

Member Function Documentation

◆ accept()

Tcp * Tcp::accept ( )
Returns
Tcp for the accepted client.

Definition at line 491 of file Tcp.cpp.

492{
493 if (use_tls)
494 {
495 #if PICO_TCP_ENABLE_TLS
496 pending_client = nullptr;
497 waiting_task = xTaskGetCurrentTaskHandle();
498 ulTaskNotifyTakeIndexed(NotifyAccept, pdTRUE, portMAX_DELAY);
499 waiting_task = nullptr;
500
501 if (pending_client)
502 {
503 Tcp *client = new Tcp();
504 client->tls_pcb = pending_client;
505 client->use_tls = true;
506 client->connected = true;
507 pending_client = nullptr;
508 return client;
509 }
510 return nullptr;
511 #else
512 printf("[Tcp] TLS not enabled in this build\n");
513 return nullptr;
514 #endif
515 }
516
517 // For plain TCP, use lwIP accept directly
518 struct sockaddr_in client_addr{};
519 socklen_t addr_len = sizeof(client_addr);
520
521 int client_fd = lwip_accept(sockfd, reinterpret_cast<struct sockaddr *>(&client_addr), &addr_len);
522 TRACE("[Tcp] Accept returned new socket: %d\n", client_fd);
523
524 if (client_fd >= 0)
525 {
526 // Set receive timeout
527 struct timeval recv_timeout = {.tv_sec = 0, .tv_usec = 100000};
528 lwip_setsockopt(client_fd, SOL_SOCKET, SO_RCVTIMEO, &recv_timeout, sizeof(recv_timeout));
529
530 // Optional: Force-close on disconnect (RST on close)
531 struct linger so_linger = {.l_onoff = 1, .l_linger = 0};
532 lwip_setsockopt(client_fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger));
533
534 Tcp *client = new Tcp(client_fd);
535 return client;
536 }
537
538 printf("[Tcp] Accept timeout, no client.\n");
539 return nullptr;
540}
#define TRACE(...)
Default trace (INFO level).
Definition DebugTrace.h:187
@ NotifyAccept
Definition Tcp.h:32
General-purpose TCP socket wrapper with optional TLS support via mbedTLS (altcp).
Definition Tcp.h:39
Tcp()
Definition Tcp.cpp:24
TaskHandle_t waiting_task
Task handle for async operations.
Definition Tcp.h:167
altcp_pcb * pending_client
For TLS: set by acceptCallback.
Definition Tcp.h:168

References connected, NotifyAccept, pending_client, sockfd, Tcp(), TRACE, use_tls, and waiting_task.

Referenced by HttpServer::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ acceptCallback()

err_t Tcp::acceptCallback ( void *  arg,
struct altcp_pcb *  new_conn,
err_t  err 
)
staticprivate

Definition at line 471 of file Tcp.cpp.

472{
473 auto *self = static_cast<Tcp *>(arg);
474
475 if (err != ERR_OK || !new_conn || !self)
476 {
477 return ERR_VAL;
478 }
479
480 self->pending_client = new_conn;
481
482 if (self->waiting_task)
483 {
484 xTaskNotifyGiveIndexed(self->waiting_task, NotifyAccept); // Notify waiting task
485 self->waiting_task = nullptr;
486 }
487
488 return ERR_OK;
489}

References NotifyAccept, and pending_client.

◆ bindAndListen()

bool Tcp::bindAndListen ( int  port)

Definition at line 542 of file Tcp.cpp.

543{
544 #if PICO_TCP_ENABLE_TLS
546 #else
547 return bindAndListenPlain(port);
548 #endif
549}
bool bindAndListenTls(int port)
bool bindAndListenPlain(int port)
Definition Tcp.cpp:552

References bindAndListenPlain(), bindAndListenTls(), and server_tls_config.

Referenced by HttpServer::initListener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bindAndListenPlain()

bool Tcp::bindAndListenPlain ( int  port)

Definition at line 552 of file Tcp.cpp.

553{
554 sockfd = lwip_socket(AF_INET, SOCK_STREAM, 0);
555 if (sockfd < 0)
556 {
557 printf("[Tcp] Failed to create socket\n");
558 return false;
559 }
560
561 int opt = 1;
562 int flags = fcntl(sockfd, F_GETFL, 0);
563 fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
564
565 struct sockaddr_in addr = {};
566 addr.sin_family = AF_INET;
567 addr.sin_port = lwip_htons(port);
568 addr.sin_addr.s_addr = PP_HTONL(INADDR_ANY);
569
570 if (lwip_bind(sockfd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(addr)) < 0)
571 {
572 printf("[Tcp] Failed to bind socket\n");
573 lwip_close(sockfd);
574 sockfd = -1;
575 return false;
576 }
577
578 if (lwip_listen(sockfd, 10) < 0)
579 {
580 printf("[Tcp] Failed to listen on socket\n");
581 lwip_close(sockfd);
582 sockfd = -1;
583 return false;
584 }
585
586 TRACE("[Tcp] Listening on port: %d, (socket: %d)\n", port, sockfd);
587
588 use_tls = false;
589 connected = true;
590 return true;
591}

References connected, sockfd, TRACE, and use_tls.

Referenced by bindAndListen().

+ Here is the caller graph for this function:

◆ bindAndListenTls()

bool Tcp::bindAndListenTls ( int  port)

Referenced by bindAndListen().

+ Here is the caller graph for this function:

◆ close()

int Tcp::close ( )

Definition at line 443 of file Tcp.cpp.

444{
445 int result = 0;
446 #if PICO_TCP_ENABLE_TLS
447 if (use_tls && tls_pcb)
448 {
449 altcp_close(tls_pcb);
450 tls_pcb = nullptr;
451 }
452 else
453 #endif
454 if (sockfd >= 0)
455 {
456 result = lwip_close(sockfd);
457 sockfd = -1;
458 }
459 recv_offset = 0;
460 waiting_task = nullptr;
461 if (recv_buffer)
462 {
463 pbuf_free(recv_buffer);
464 recv_buffer = nullptr;
465 }
466
467 connected = false;
468 return result;
469}
struct pbuf * recv_buffer
Buffer for TLS receive.
Definition Tcp.h:155
size_t recv_offset
Definition Tcp.h:156

References connected, recv_buffer, recv_offset, sockfd, use_tls, and waiting_task.

Referenced by HttpServer::handleClient(), HttpServer::startHandlingClient(), and ~Tcp().

+ Here is the caller graph for this function:

◆ connect()

bool Tcp::connect ( const char *  host,
int  port,
bool  useTls = false 
)
Parameters
hostHostname or IP address.
portPort number.
Returns
true on success, false on failure.

Definition at line 116 of file Tcp.cpp.

117{
118 strncpy(hostname, host, sizeof(hostname) - 1);
119 this->use_tls = use_tls;
120 ip_addr_t ip;
121 if (!resolveHostnameBlocking(host, &ip))
122 {
123 printf("[Tcp] DNS resolution failed for %s\n", host);
124 return false;
125 }
126#if PICO_TCP_ENABLE_TLS
127 return use_tls ? connectTls(ip, port) : connectPlain(ip, port);
128#else
129 return connectPlain(ip, port);
130#endif
131}
char hostname[64]
Hostname for TLS connections.
Definition Tcp.h:170
bool connectTls(const ip_addr_t &ip, int port)
bool connectPlain(const ip_addr_t &ip, int port)
Definition Tcp.cpp:133
bool resolveHostnameBlocking(const char *hostname, ip_addr_t *result, uint32_t timeout_ms=5000)
Blocking DNS resolution using lwIP.

References connectPlain(), connectTls(), hostname, resolveHostnameBlocking(), and use_tls.

+ Here is the call graph for this function:

◆ connectPlain()

bool Tcp::connectPlain ( const ip_addr_t &  ip,
int  port 
)
private

Definition at line 133 of file Tcp.cpp.

134{
135 struct sockaddr_in addr = {};
136 addr.sin_family = AF_INET;
137 addr.sin_port = lwip_htons(port);
138 addr.sin_addr.s_addr = ip.addr;
139
140 sockfd = lwip_socket(AF_INET, SOCK_STREAM, 0);
141 if (sockfd < 0)
142 {
143 printf("[Tcp] Failed to create socket\n");
144 return false;
145 }
146
147 if (lwip_connect(sockfd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(addr)) < 0)
148 {
149 printf("[Tcp] Failed to connect to server\n");
150 lwip_close(sockfd);
151 sockfd = -1;
152 return false;
153 }
154 TRACE("[Tcp] Connected to server (plain)\n");
155 connected = true;
156 use_tls = false;
157 return true;
158}

References connected, sockfd, TRACE, and use_tls.

Referenced by connect().

+ Here is the caller graph for this function:

◆ connectTls()

bool Tcp::connectTls ( const ip_addr_t &  ip,
int  port 
)
private

Referenced by connect().

+ Here is the caller graph for this function:

◆ getHostname()

const char * Tcp::getHostname ( ) const
inline

Definition at line 132 of file Tcp.h.

132{ return hostname; }

References hostname.

◆ getPeerIp()

std::string Tcp::getPeerIp ( ) const

Definition at line 79 of file Tcp.cpp.

80{
81 sockaddr_in addr;
82 socklen_t len = sizeof(addr);
83 if (lwip_getpeername(sockfd, reinterpret_cast<sockaddr *>(&addr), &len) == 0)
84 {
85 ip_addr_t ip;
86 ip.addr = addr.sin_addr.s_addr;
87 return std::string(ipaddr_ntoa(&ip));
88 }
89 return "0.0.0.0";
90}

References sockfd.

◆ getSocketFd()

int Tcp::getSocketFd ( ) const
inline

Definition at line 124 of file Tcp.h.

124{ return sockfd; }

References sockfd.

Referenced by getClientIpFromTcp(), HttpResponse::getSocket(), and HttpRequest::receive().

+ Here is the caller graph for this function:

◆ isConnected()

bool Tcp::isConnected ( ) const
inline

Definition at line 119 of file Tcp.h.

119{ return connected; }

References connected.

Referenced by MultipartParser::sendHttpResponse().

+ Here is the caller graph for this function:

◆ isValid()

bool Tcp::isValid ( ) const
inline

Definition at line 113 of file Tcp.h.

113{ return sockfd >= 0; }

References sockfd.

◆ operator=() [1/2]

Tcp & Tcp::operator= ( const Tcp )
delete

◆ operator=() [2/2]

Tcp & Tcp::operator= ( Tcp &&  other)
noexcept

Definition at line 54 of file Tcp.cpp.

55{
56 if (this != &other)
57 {
58 sockfd = other.sockfd;
59 #if PICO_TCP_ENABLE_TLS
60 tls_pcb = other.tls_pcb;
61 tls_config = other.tls_config;
63 #endif
64 connected = other.connected;
65 use_tls = other.use_tls;
67
68 other.sockfd = -1;
69 #if PICO_TCP_ENABLE_TLS
70 other.tls_pcb = nullptr;
71 other.tls_config = nullptr;
72 other.server_tls_config = nullptr;
73 #endif
74 other.recv_buffer = nullptr;
75 }
76 return *this;
77}

References sockfd.

◆ recv()

int Tcp::recv ( char *  buffer,
size_t  size,
uint32_t  timeout_ms 
)

Definition at line 389 of file Tcp.cpp.

390{
391 if (!use_tls)
392 {
393 TRACE("Plain recv: %zu bytes\n", size);
394 int received = lwip_recv(sockfd, buffer, size, 0);
395 if (received < 0)
396 {
397 TRACE("Plain recv error: %d, %s\n", errno, strerror(errno));
398 return received;
399 }
400 return received;
401 }
402
403#if PICO_TCP_ENABLE_TLS
404 if (!tls_pcb || !buffer || size == 0)
405 {
406 return -1;
407 }
408
409 // If no data available yet, block and wait for notify
410 if (!recv_buffer)
411 {
412 waiting_task = xTaskGetCurrentTaskHandle();
413 BaseType_t result = ulTaskNotifyTakeIndexed(NotifyRecv, pdTRUE, pdMS_TO_TICKS(timeout_ms));
414 if (result == 0 || !recv_buffer)
415 return 0; // timeout or nothing delivered
416 }
417
418 if (!recv_buffer)
419 {
420 return 0; // Nothing was delivered even after wakeup
421 }
422
423 // Copy as much as we can from the pbuf to the buffer
424 size_t available = recv_buffer->tot_len - recv_offset;
425 size_t to_copy = (size < available) ? size : available;
426 pbuf_copy_partial(recv_buffer, buffer, to_copy, recv_offset);
427 recv_offset += to_copy;
428
429 // If we've consumed the full pbuf, release it
430 if (recv_offset >= recv_buffer->tot_len)
431 {
432 pbuf_free(recv_buffer);
433 recv_buffer = nullptr;
434 recv_offset = 0;
435 }
436 return static_cast<int>(to_copy);
437#else
438 printf("[Tcp] TLS not enabled in this build\n");
439 return -1;
440#endif
441}
@ NotifyRecv
Definition Tcp.h:31

References NotifyRecv, recv_buffer, recv_offset, sockfd, TRACE, use_tls, and waiting_task.

Referenced by HttpRequest::appendRemainingBody(), MultipartParser::handleMultipart(), HttpParser::receiveChunkedBodyToFile(), HttpParser::receiveChunkedBodyToString(), HttpParser::receiveFixedLengthBodyToFile(), HttpParser::receiveFixedLengthBodyToString(), HttpParser::receiveHeaderAndLeftover(), HttpParser::receiveUnknownLengthBodyToString(), and HttpRequest::receiveUntilHeadersComplete().

+ Here is the caller graph for this function:

◆ send()

int Tcp::send ( const char *  buffer,
size_t  size 
)

Definition at line 279 of file Tcp.cpp.

280{
281 TRACE("[Tcp] Sending %zu bytes\n", size);
282 #if PICO_TCP_ENABLE_TLS
283 if ((!buffer && size > 0) || !connected || (use_tls && !tls_pcb))
284#else
285 if ((!buffer && size > 0) || !connected)
286#endif
287 {
288 printf("[Tcp] Invalid buffer, size, or connection\n");
289 return -1;
290 }
291
292 constexpr size_t chunkSize = HTTP_BUFFER_SIZE;
293 size_t totalSent = 0;
294
295 // absolute_time_t startTime = get_absolute_time(); // <-- your timing starts here
296
297 while (totalSent < size)
298 {
299 size_t toSend = (size - totalSent > chunkSize) ? chunkSize : (size - totalSent);
300 #if PICO_TCP_ENABLE_TLS
301 if (use_tls && tls_pcb)
302 {
303
304 if (tls_pcb->state == nullptr)
305 {
306 printf("[Tcp] TLS connection is not established\n");
307 return -1;
308 }
309
310 err_t err = altcp_write(tls_pcb, buffer + totalSent, toSend, TCP_WRITE_FLAG_COPY);
311 if (err != ERR_OK)
312 {
313 printf("[Tcp] altcp_write failed: %d\n", err);
314 return -1;
315 }
316 if (altcp_output(tls_pcb) != ERR_OK)
317 {
318 printf("[Tcp] altcp_output failed\n");
319 return -1;
320 }
321 }
322
323 else
324 #endif
325 if (sockfd >= 0)
326 {
327 int ret = lwip_send(sockfd, buffer + totalSent, toSend, 0);
328 if (ret <= 0)
329 {
330 warning("[Tcp] lwip_send failed: ", ret);
331 return -1;
332 }
333 }
334 else
335 {
336 printf("[Tcp] No valid socket or TLS connection\n");
337 return -1;
338 }
339
340 vTaskDelay(pdMS_TO_TICKS(STREAM_SEND_DELAY_MS)); // Throttle per chunk
341 totalSent += toSend;
342 }
343
344 // After sending ALL chunks: yield and delay for TCP flush
345 taskYIELD();
346 vTaskDelay(pdMS_TO_TICKS(20)); // Give lwIP time to transmit the data
347
348 return static_cast<int>(size); // Report success
349}
#define HTTP_BUFFER_SIZE
Size of the HTTP buffer for request/response data.
#define STREAM_SEND_DELAY_MS
void warning(const std::string &msg)
Definition utility.cpp:215

References connected, HTTP_BUFFER_SIZE, sockfd, STREAM_SEND_DELAY_MS, TRACE, use_tls, and warning().

Referenced by HttpResponse::send(), HttpResponse::sendHeaders(), MultipartParser::sendHttpResponse(), HttpResponse::start(), and HttpResponse::writeChunk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHostname()

void Tcp::setHostname ( const char *  name)
inline

Definition at line 126 of file Tcp.h.

126 {
127 if (name) {
128 strncpy(hostname, name, sizeof(hostname) - 1);
129 hostname[sizeof(hostname) - 1] = '\0';
130 }
131 }

References hostname.

◆ setRootCACertificate()

void Tcp::setRootCACertificate ( const std::string &  pem)

◆ setServerTlsConfig()

void Tcp::setServerTlsConfig ( const std::string &  certPem,
const std::string &  keyPem 
)

◆ tlsRecvCallback()

err_t Tcp::tlsRecvCallback ( void *  arg,
struct altcp_pcb *  conn,
struct pbuf *  p,
err_t  err 
)
staticprivate

Definition at line 351 of file Tcp.cpp.

352{
353 auto *self = static_cast<Tcp *>(arg);
354 if (!self)
355 return ERR_VAL;
356
357 if (!p)
358 {
359 // Remote closed connection
360 if (self->recv_buffer)
361 {
362 pbuf_free(self->recv_buffer);
363 self->recv_buffer = nullptr;
364 }
365 self->recv_offset = 0;
366 return ERR_OK;
367 }
368
369 // Drop if already have a pbuf (single-buffer policy for now)
370 if (self->recv_buffer)
371 {
372 pbuf_free(p); // Drop additional pbuf to prevent overflow
373 return ERR_OK;
374 }
375
376 self->recv_buffer = p;
377 self->recv_offset = 0;
378
379 // Notify any task waiting in recv()
380 if (self->waiting_task)
381 {
382 xTaskNotifyGiveIndexed(self->waiting_task, NotifyRecv);
383 self->waiting_task = nullptr;
384 }
385
386 return ERR_OK;
387}

References NotifyRecv.

Member Data Documentation

◆ connected

bool Tcp::connected = false
private

Definition at line 143 of file Tcp.h.

Referenced by accept(), bindAndListenPlain(), close(), connectPlain(), isConnected(), and send().

◆ connectingTask

TaskHandle_t Tcp::connectingTask = nullptr
private

Definition at line 166 of file Tcp.h.

◆ connectResult

int Tcp::connectResult = ERR_OK
private

Definition at line 146 of file Tcp.h.

◆ hostname

char Tcp::hostname[64] = {0}
private

Definition at line 170 of file Tcp.h.

170{0};

Referenced by connect(), getHostname(), and setHostname().

◆ is_server_socket

bool Tcp::is_server_socket = false
private

Definition at line 145 of file Tcp.h.

◆ MAX_TLS_SEGMENT_SIZE

constexpr size_t Tcp::MAX_TLS_SEGMENT_SIZE = 1460
staticconstexprprivate

Definition at line 164 of file Tcp.h.

◆ pending_client

altcp_pcb* Tcp::pending_client = nullptr
private

Definition at line 168 of file Tcp.h.

Referenced by accept(), and acceptCallback().

◆ recv_buffer

struct pbuf* Tcp::recv_buffer = nullptr
private

Definition at line 155 of file Tcp.h.

Referenced by close(), and recv().

◆ recv_offset

size_t Tcp::recv_offset = 0
private

Definition at line 156 of file Tcp.h.

Referenced by close(), and recv().

◆ root_ca_cert

std::string Tcp::root_ca_cert
private

Definition at line 148 of file Tcp.h.

◆ server_tls_cert

std::string Tcp::server_tls_cert
private

Definition at line 159 of file Tcp.h.

◆ server_tls_config

struct altcp_tls_config* Tcp::server_tls_config = nullptr
private

Definition at line 161 of file Tcp.h.

Referenced by bindAndListen().

◆ server_tls_key

std::string Tcp::server_tls_key
private

Definition at line 160 of file Tcp.h.

◆ sockfd

int Tcp::sockfd = -1
private

◆ use_tls

bool Tcp::use_tls = false
private

Definition at line 144 of file Tcp.h.

Referenced by accept(), bindAndListenPlain(), close(), connect(), connectPlain(), recv(), and send().

◆ waiting_task

TaskHandle_t Tcp::waiting_task = nullptr
private

Definition at line 167 of file Tcp.h.

Referenced by accept(), close(), and recv().


The documentation for this class was generated from the following files: