KROYSDOCS
HomeWhat's newv0.1.0
C/C++ SDK / C ABI · Loopback networking (editor; permission network.loopback) / KroysNetApi

KroysNetApi

Loopback TCP for tools that talk to other programs on this machine (permission network.loopback). Editor target only.

Kindstruct
Headerkroys/kroys_plugin.h
Members9
Functions7
DECLARATION

Declaration

Declared in kroys/kroys_plugin.h.

kroys_plugin.h
typedef struct KroysNetApi { ... } KroysNetApi;
REFERENCE

Members

Fields
#uint32_t structSize;

Size of this struct as the writer compiled it (sizeof); the reader uses it to detect members appended by later minor versions.

field
#uint32_t reserved;

Padding reserved for later use; leave it 0.

field
Functions
#KroysResult (KROYS_CALL* OpenListener)(KroysContext context, uint16_t port, KroysHandle* outListener);

TCP listener on KROYS_NET_BIND when it is a 127.x address, else 127.0.0.1 (never another interface). Port 0: any free port.

function pointer
#uint16_t (KROYS_CALL* ListenerPort)(KroysContext context, KroysHandle listener);

The port a listener is bound to.

function pointer
#const char* (KROYS_CALL* ListenerAddress)(KroysContext context, KroysHandle listener);

The address a listener is bound to ("127.0.0.1"; host string).

function pointer
#KroysResult (KROYS_CALL* Accept)(KroysContext context, KroysHandle listener, KroysHandle* outConnection);

Non-blocking; *outConnection = 0 when nothing is pending.

function pointer
#int64_t (KROYS_CALL* Receive)(KroysContext context, KroysHandle connection, void* buffer, size_t capacity);

Bytes read (> 0), 0 when nothing is pending, -1 once closed or on an error.

function pointer
#int64_t (KROYS_CALL* Send)(KroysContext context, KroysHandle connection, const void* data, size_t size);

Bytes queued (may be fewer), -1 on an error.

function pointer
#KroysResult (KROYS_CALL* Close)(KroysContext context, KroysHandle handle);

Closes a listener or connection; the handle becomes invalid.

function pointer
Members
uint32_t structSize;
uint32_t reserved;
KroysResult (KROYS_CALL* OpenListener)(KroysContext context, uint16_t port, KroysHandle* outListener);
uint16_t (KROYS_CALL* ListenerPort)(KroysContext context, KroysHandle listener);
const char* (KROYS_CALL* ListenerAddress)(KroysContext context, KroysHandle listener);
KroysResult (KROYS_CALL* Accept)(KroysContext context, KroysHandle listener, KroysHandle* outConnection);
int64_t (KROYS_CALL* Receive)(KroysContext context, KroysHandle connection, void* buffer, size_t capacity);
int64_t (KROYS_CALL* Send)(KroysContext context, KroysHandle connection, const void* data, size_t size);
KroysResult (KROYS_CALL* Close)(KroysContext context, KroysHandle handle);

KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.