CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
NetEvent Struct Reference

Network Event Structure. More...

#include <net_shared.h>

Data Fields

NetEventType event
 Type of event.
 
NetQueuequeue
 Originating NetQueue.
 
NetSocketsocket
 Associated socket.
 
NetFlowflow
 Flow the event belongs to, or NULL for socket-wide events.
 
void * ctx
 The context pointer passed to netflowSetHandlers / netsocketSetHandlers / netqueueSetHandlers when this handler was registered.
 
union { 
 
   struct { 
 
      NetConnectionState   state 
 Current connection state.
 
      NetErrorCode   err 
 Error code if connection failed (NERR_None if successful)
 
   }   conn 
 NET_Connection event data.
 
   struct { 
 
   }   accept 
 NET_Accepted.
 
   struct { 
 
      size_t   bytes 
 Number of bytes received.
 
      size_t   total 
 Total bytes pending in receive buffer.
 
      struct NetMessage *   msg 
 Datagram: the packet itself. NULL for stream sockets. More...
 
   }   recv 
 NET_DataReceived.
 
   struct { 
 
      NetErrorCode   err 
 Error code.
 
   }   error 
 NET_Error.
 
   struct { 
 
      NetFilterNotify   notify 
 Which notification the filter raised (NFN_Secured, ...)
 
   }   filter 
 NET_FilterNotify.
 
   struct { 
 
      struct NetMessage *   msg 
 The packet that could not be assigned a flow.
 
   }   refused 
 NET_FlowRefused (NET_FlowOpen carries no event data; the flow itself is the payload)
 
   struct { 
 
      NetCloseReason   reason 
 Why the flow is being torn down.
 
   }   closed 
 NET_FlowClosed.
 
   struct { 
 
      NetTimerId   id 
 Which of the flow's armed timers reached its deadline.
 
   }   timer 
 NET_Timer.
 
};  
 Event-specific data.
 

Detailed Description

Network Event Structure.

Definition at line 600 of file net_shared.h.

Field Documentation

◆ ctx

void* NetEvent::ctx

The context pointer passed to netflowSetHandlers / netsocketSetHandlers / netqueueSetHandlers when this handler was registered.

This is the right place for per-socket and per-queue application state; only flows carry a user array (see Application state).

Definition at line 617 of file net_shared.h.

◆ err

NetErrorCode NetEvent::err

Error code if connection failed (NERR_None if successful)

Error code.

Definition at line 624 of file net_shared.h.

◆ flow

NetFlow* NetEvent::flow

Flow the event belongs to, or NULL for socket-wide events.

Stream sockets have exactly one flow, created during socket init; consumers that only ever handle a single connection can ignore this field entirely. Datagram sockets have one flow per peer address.

Definition at line 610 of file net_shared.h.

◆ msg

struct NetMessage* NetEvent::msg

Datagram: the packet itself. NULL for stream sockets.

The packet that could not be assigned a flow.

Set msg->buf to NULL to take ownership of the payload; otherwise it is returned to the pool when the handler returns. Stream sockets buffer into a ring instead – call netsocketRecv() or netsocketRecvMsgs() to drain it.

Definition at line 642 of file net_shared.h.


The documentation for this struct was generated from the following file: