power_play/src/net/net.h
2026-01-15 17:51:50 -06:00

53 lines
1.0 KiB
C

////////////////////////////////////////////////////////////
//~ Opaque types
Struct(NET_PipeHandle) { u64 v; };
#define NET_IsPipeNil(h) ((h).v == 0)
////////////////////////////////////////////////////////////
//~ Key types
Struct(NET_Key)
{
u64 v;
};
#define NET_NilKey ((NET_Key) { 0 })
#define NET_IsKeyNil(k) ((k).v == 0)
////////////////////////////////////////////////////////////
//~ Message types
Struct(NET_Msg)
{
NET_Msg *next;
NET_Msg *prev;
NET_Key src;
String data;
};
Struct(NET_MsgList)
{
i64 count;
NET_Msg *first;
NET_Msg *last;
};
////////////////////////////////////////////////////////////
//~ @hookdecl Bootstrap
void NET_Bootstrap(void);
////////////////////////////////////////////////////////////
//~ @hookdecl Net ops
NET_PipeHandle NET_AcquirePipe(void);
void NET_Bind(NET_PipeHandle pipe, u64 port);
u64 NET_BoundPortFromPipe(NET_PipeHandle pipe_handle);
void NET_Push(NET_PipeHandle pipe_handle, NET_Key dst, String data, b32 unreliable);
NET_MsgList NET_Pop(Arena *arena, NET_PipeHandle pipe);