20#define NET_INVALID_HANDLE ((NetSockHandle)-1)
112typedef void (*NetSendPumpFn)(
void* ctx,
NetSocket* sock);
118typedef void (*NetWakeFn)(
void* ctx);
185#define NET_FILTER_RING_SEGSZ 16384
232typedef struct NetTimerEntry {
299#define SType_NetAddr NetAddr*
300#define STStorageType_NetAddr NetAddr
301#define STypeArg_NetAddr(type, val) stgeneric(opaque, &(val))
302#define STypeArgPtr_NetAddr(type, val) &stgeneric(opaque, (val))
303#define STypeCheckedArg_NetAddr(type, val) stType(type), stArg(type, val)
304#define STypeCheckedPtrArg_NetAddr(type, val) stType(type), stArgPtr(type, val)
398typedef struct NetSocketBufs {
427#define netMsgQueueEmpty(q) ((q)->head == NULL)
Buffer chain implementation for efficient streaming I/O.
Simple buffer management.
Ring buffer implementation for efficient streaming I/O.
void(* NetConnectPrepCB)(NetSocket *sock, void *ctx)
NetEventType
Network event types.
void(* NetEventCB)(NetEvent *event)
@ NET_FlowClosed
A flow is being torn down; release any state hanging off flow->user.
@ NET_Connection
A connection attempt resolved.
@ NET_SendReady
The send backlog drained; sending can resume.
@ NET_Accepted
A listening socket accepted an incoming connection.
@ NET_FilterNotify
A filter raised an out-of-band notification.
@ NET_DataReceived
Data arrived on a socket.
@ NET_FlowOpen
A flow was created for a new peer.
@ NET_Error
An error surfaced asynchronously on the socket.
@ NET_Timer
A timer armed on this flow reached its deadline.
@ NET_FlowRefused
A packet arrived from a source with no flow, and none could be created.
NetEcn
Explicit Congestion Notification codepoint, as carried in the IP header.
NetAddrType
Network address types.
NetTimerFlags
Flags controlling how an armed timer behaves.
intptr NetSockHandle
Platform-neutral OS socket handle: a Windows SOCKET or a Unix file descriptor.
uint64 NetTimerId
Handle to an armed timer, unique for the lifetime of its queue.
NetSocketOpFlags
Flags for socket send/receive operations.
NetQueueFlags
Flags for creating a NetQueue.
NetConnectionState
Network connection states (for event notification)
NetErrorCode
Network error codes.
NetSocketState
State of a network socket.
void netMsgQueuePush(NetMsgQueue *q, NetMessage *msg)
NetMessage * netMsgQueuePop(NetMsgQueue *q)
NetSocketType
Socket types.
@ NET_ECN_CE
Congestion experienced: a router marked this packet on the way.
@ NET_ECN_Ect0
ECN-capable transport, codepoint 0.
@ NET_ECN_NotEct
Not ECN-capable: a congested router drops this packet.
@ NET_ECN_Ect1
ECN-capable transport, codepoint 1.
@ NA_Unknown
Unknown or invalid.
@ NCR_Error
Connection reset or other fatal socket error.
@ NCR_Shutdown
The queue is shutting down.
@ NCR_SocketClosed
The owning socket was closed with flows still live.
@ NCR_Reclaimed
Reclaimed under flow cap pressure (resurrectable)
@ NCR_AppClosed
Application called netflowClose()
@ NCR_PeerClosed
Stream peer closed the connection cleanly.
@ NTF_Repeat
Re-arm automatically after each fire, at the same delay.
@ NCP_PreferV6
Interleave, but IPv6 leads regardless of resolver order.
@ NCP_Default
Interleave; the first address the resolver returned leads.
@ NCP_V6Only
Discard every IPv4 result.
@ NCP_V4Only
Discard every IPv6 result.
@ NCP_PreferV4
Interleave, but IPv4 leads regardless of resolver order.
@ NSO_Peek
For receive operations, peek at the data without removing it from the socket buffer.
@ NSO_None
No special options.
@ NQ_AutoAccept
Automatically add accepted sockets to the queue.
@ NQ_SelectOnly
Force use of the select() API, even if more efficient backends are available.
@ NCS_Connecting
Connection in progress.
@ NCS_Connected
Connected.
@ NCS_NotConnected
Not connected.
@ NERR_Interrupted
Interrupted by a signal before anything was transferred.
@ NERR_HostUnreachable
Host is unreachable.
@ NERR_NetworkDown
Network is down.
@ NERR_ConnectionRefused
Connection was refused by the remote host.
@ NERR_ConnectionReset
Connection was reset by peer.
@ NERR_AddressInUse
Address already in use.
@ NERR_WouldBlock
The operation would have blocked; no data available yet.
@ NERR_Unknown
Unknown error.
@ NERR_AlreadyConnected
Socket is already connected.
@ NERR_Timeout
Connection timed out.
@ NERR_NetworkUnreachable
Network is unreachable.
@ NERR_NotConnected
Socket is not connected.
@ NS_Closed
Socket is closed and cannot be reused.
@ NS_Connected
Socket is connected (default for bound connectionless sockets)
@ NS_Resolving
Waiting for name resolution.
@ NS_Listening
Socket is listening for incoming connections.
@ NS_Connecting
Socket is in the process of connecting.
@ NS_Init
Socket is not yet used.
@ NFN_Secured
The filter's secure channel is up; the application may send now.
@ NFN_None
No notification.
@ NFN_AppCustom
First code reserved for application-defined filter notifications.
@ NST_Quic
QUIC connection or listener, implemented by cxquic on top of a datagram socket.
Lock-free pointer FIFO queue.
Dynamic arrays with type-safe generic programming.
uint8 ipv6[16]
IPv6 address.
uint8 ipv4[4]
IPv4 address.
uint32 scope
Scope ID (for IPv6)
NetAddrType type
Address type (NA_IPv4, NA_IPv6)
struct NetEvent::@11::@17 filter
NET_FilterNotify.
struct NetEvent::@11::@15 recv
NET_DataReceived.
struct NetEvent::@11::@13 conn
NET_Connection event data.
NetCloseReason reason
Why the flow is being torn down.
size_t total
Total bytes pending in receive buffer.
NetQueue * queue
Originating NetQueue.
NetErrorCode err
Error code if connection failed (NERR_None if successful)
NetSocket * socket
Associated socket.
struct NetMessage * msg
Datagram: the packet itself. NULL for stream sockets.
NetTimerId id
Which of the flow's armed timers reached its deadline.
NetEventType event
Type of event.
struct NetEvent::@11::@19 closed
NET_FlowClosed.
struct NetEvent::@11::@18 refused
NET_FlowRefused (NET_FlowOpen carries no event data; the flow itself is the payload)
struct NetEvent::@11::@16 error
NET_Error.
struct NetEvent::@11::@14 accept
NET_Accepted.
void * ctx
The context pointer passed to netflowSetHandlers / netsocketSetHandlers / netqueueSetHandlers when th...
NetConnectionState state
Current connection state.
NetFlow * flow
Flow the event belongs to, or NULL for socket-wide events.
size_t bytes
Number of bytes received.
struct NetEvent::@11::@20 timer
NET_Timer.
NetFilterNotify notify
Which notification the filter raised (NFN_Secured, ...)
A single ordering domain: one connection, or one datagram peer.
Set of event handlers, registered per flow, per socket, or queue-wide.
NetEventCB flowClosed
NET_FlowClosed: release state hanging off flow->user.
NetEventCB sendReady
NET_SendReady: send buffer drained below the low watermark.
NetEventCB error
NET_Error: a queued send failed asynchronously.
NetEventCB flowRefused
NET_FlowRefused: packet from an unknown source, no flow made.
NetEventCB connection
NET_Connection: established, failed, or state changed.
NetEventCB accepted
NET_Accepted: new incoming connection.
NetEventCB flowOpen
NET_FlowOpen: a flow was created; set up state on flow->user.
NetEventCB recv
NET_DataReceived: stream data or a complete datagram.
NetEventCB timer
NET_Timer: a timer armed on the flow reached its deadline.
NetEventCB filterNotify
NET_FilterNotify: a filter raised a notification (NFN_Secured, ...)
A received packet, as delivered to a handler.
NetPktInfo info
What the IP layer carried with this datagram, where the platform could report it.
NetAddr addr
Source / destination address.
Buffer buf
Message data (NULL for stream data, which is buffered in the socket's ring)
Simple intrusive FIFO of NetMessage, linked through NetMessage::next.
NetMessage * tail
Newest queued message, or NULL if empty.
NetMessage * head
Oldest queued message, or NULL if empty.
Per-datagram information the IP layer carries alongside the payload.
bool haveEcn
ecn is filled in
uint8 ecn
NetEcn codepoint; only meaningful when haveEcn is set.
NetAddr local
Receive: the local address the datagram arrived on. Send: the address to leave from.
bool haveLocal
local is filled in
int64 connectAttemptTimeout
Shorter timeout for connect attempts other than the last remaining address of their family,...
bool noReclaim
Never reclaim, even at the cap.
int64 reclaimMinIdle
Minimum time a flow must have been idle before cap-pressure reclaim may evict it, in microseconds (0 ...
uint32 reclaimBatch
Flows to reclaim per cap hit.
uint32 recvBufInitial
Buffers preallocated at queue creation.
int64 connectTimeout
How long a single connect attempt may run before it's cancelled and the next resolved address is trie...
int32 nthreads
Number of worker threads, or 0 for polled mode.
size_t recvBufSize
Size of each pooled receive buffer.
flags_t flags
NetQueueFlags.
NetConnectPref connectPref
Default address-family preference for connects on this queue (see NetConnectPref)
uint32 maxflows
Cap on concurrent flows across the queue (0 = unlimited)
uint32 recvBufMax
Hard cap on live buffers; the receive memory ceiling.
size_t sendHigh
Default send high watermark for sockets on this queue.
NetQueue manages one or more sockets and a thread pool of workers.
Runtime type system and type descriptor infrastructure.