ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
tcp.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file tcp.h
6 * @brief Layer 4 (Transport), connection oriented: the three sides of TCP, joined.
7 *
8 * One module with three halves, because a connection is reached three ways. The listener binds a
9 * port and accepts on it, the pool holds what was accepted, and the client dials out. All three
10 * speak to the same stack and hand out slot indices and rings, so no stack type reaches a layer
11 * above this one.
12 *
13 * Each half is reached through its own handle: ::ConnPool, ::TcpListener, ::TcpClient. The
14 * halves are pointers rather than values because a table in one translation unit is not a constant
15 * expression in another, so a by-value member could not be initialized from here.
16 *
17 * The per-slot ring accessors stay inline in common.h rather than becoming members. A member
18 * is an indirect call through rodata; those accessors are a load and a compare on the request path.
19 *
20 * @author Douglas Quigg (dstroy0)
21 * @date 2026
22 */
23
24#ifndef PROTOCORE_TCP_H
25#define PROTOCORE_TCP_H
26
27#include "protocore_config.h" // the entry point: the enable gate below, and the widths
28
29#if PROTOCORE_ENABLE_TCP
30
31#if PROTOCORE_ENABLE_TCP_CLIENT
32#include "network_drivers/transport/tcp/client/client.h" // TcpClientNs: dialing out
33#endif
34#include "network_drivers/transport/tcp/protocol/protocol.h" // ConnPoolNs: the accepted connections
35#include "network_drivers/transport/tcp/server/server.h" // TcpListenerNs: the bound ports
37
38/**
39 * @brief The connection oriented transport.
40 *
41 * @var TcpNs::conn the pool of accepted connections
42 * @var TcpNs::listener bound ports, their worker queues, and the accept-time gates
43 * @var TcpNs::client dialing out; present only when a client transport is enabled
44 *
45 * Pointers rather than values because a table in one translation unit is not a constant expression
46 * in another, so a by-value member could not be initialized from tcp.c.
47 */
48typedef struct
49{
50 ConnPoolNs *const conn;
51 TcpListenerNs *const listener;
52#if PROTOCORE_ENABLE_TCP_CLIENT
53 TcpClientNs *const client;
54#endif
55} TcpNs;
56
57/** @brief The one symbol this module exports. */
58extern TcpNs Tcp;
59
61
62#endif // PROTOCORE_ENABLE_TCP
63
64#endif // PROTOCORE_TCP_H
Layer 4 (Transport) - the user/TCP interface and the event processing behind it.
The entries.
Definition protocol.h:179
The entries.
Definition server.h:139
Layer 4 (Transport) - the active OPEN: the outbound client transport.
Layer 4 (Transport) - the passive OPEN: bound ports and their accept-time gates.
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
#define PROTOCORE_END_DECLS
Definition types.h:97