ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
server.h File Reference

Layer 4 UDP, the receiving side: bound ports, their receive rings, and the drain. More...

#include "shared/ip/ip.h"
#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  UdpBindArgs
 RFC 768 "the creation of new receive ports": what binding one takes. More...
 
struct  UdpSendArgs
 RFC 768 "an operation that allows a datagram to be sent": where it goes and what it carries. More...
 
struct  UdpPeerArgs
 RFC 768 "an indication of source port and source address": the sender a reply answers. More...
 
struct  UdpListenerVars
 
struct  UdpListenerNs
 The entries. More...
 

Typedefs

typedef void(* protocore_udp_handler) (const uint8_t *data, size_t len, const struct protocore_udp_peer *peer, void *ctx)
 Datagram handler, invoked once per received datagram by poll().
 

Functions

void protocore_udp_listener_listen (uint8_t *work)
 
void protocore_udp_listener_listen_multicast (uint8_t *work)
 
void protocore_udp_listener_leave_multicast (uint8_t *work)
 
void protocore_udp_listener_poll (uint8_t *work)
 
void protocore_udp_listener_reply (uint8_t *work)
 
void protocore_udp_listener_peer_addr (uint8_t *work)
 
void protocore_udp_listener_sendto (uint8_t *work)
 
void protocore_udp_listener_close (uint8_t *work)
 
void protocore_udp_listener_joined_group (uint8_t *work)
 
uint8_t * protocore_udp_listener_span (void)
 The PROTOCORE_UDP_LISTENER_BORROW bytes this module's state lives in.
 

Variables

UdpListenerVars UdpListenerV
 The operands and the outcome.
 

Detailed Description

Layer 4 UDP, the receiving side: bound ports, their receive rings, and the drain.

One slot per bound port, and one receive ring per slot. The stack's receive trampoline is its sole producer; poll() is its sole consumer and calls the handler once per datagram, so the handler runs in the task that calls poll(), not in the stack's thread.

The ring carries framed entries: address, port, and length ahead of the payload. A frame is published once, whole, so the consumer never observes a partial one, and a datagram that does not fit the free space is dropped at the trampoline.

Sending is not queued. reply() and sendto() carry the caller's buffer to the wire inside one marshaled call and report what the stack did with it.

Reached through ::UdpListener.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file server.h.

Typedef Documentation

◆ protocore_udp_handler

typedef void(* protocore_udp_handler) (const uint8_t *data, size_t len, const struct protocore_udp_peer *peer, void *ctx)

Datagram handler, invoked once per received datagram by poll().

Parameters
datacontiguous payload, staged out of the slot's receive ring.
lenpayload length in bytes.
peerreply token, valid only during this call.
ctxthe opaque context passed to listen().

Definition at line 51 of file server.h.

Function Documentation

◆ protocore_udp_listener_listen()

void protocore_udp_listener_listen ( uint8_t *  work)

◆ protocore_udp_listener_listen_multicast()

void protocore_udp_listener_listen_multicast ( uint8_t *  work)

◆ protocore_udp_listener_leave_multicast()

void protocore_udp_listener_leave_multicast ( uint8_t *  work)

◆ protocore_udp_listener_poll()

void protocore_udp_listener_poll ( uint8_t *  work)

◆ protocore_udp_listener_reply()

void protocore_udp_listener_reply ( uint8_t *  work)

◆ protocore_udp_listener_peer_addr()

void protocore_udp_listener_peer_addr ( uint8_t *  work)

◆ protocore_udp_listener_sendto()

void protocore_udp_listener_sendto ( uint8_t *  work)

◆ protocore_udp_listener_close()

void protocore_udp_listener_close ( uint8_t *  work)

◆ protocore_udp_listener_joined_group()

void protocore_udp_listener_joined_group ( uint8_t *  work)

◆ protocore_udp_listener_span()

uint8_t * protocore_udp_listener_span ( void  )

The PROTOCORE_UDP_LISTENER_BORROW bytes this module's state lives in.

Stated beside the namespace rather than on it: an entry takes a borrow, and this is where that borrow comes from. Taken once from the end of the pool, which no mark and no release walks, so the state lasts the life of the program.

Returns
the span.

Variable Documentation

◆ UdpListenerV

UdpListenerVars UdpListenerV
extern

The operands and the outcome.