.TH "net.h" 3 "Bark" \" -*- nroff -*- .ad l .nh .SH NAME net.h \- Bark asynchronous HTTPS and WebSocket client primitives\&. .SH SYNOPSIS .br .PP .SS "Classes" .in +1c .ti -1c .RI "struct \fBbark_net_cbs\fP" .br .RI "Main-thread network event callbacks dispatched by \fBbark_net_poll()\fP\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef struct bark_net \fBbark_net_t\fP" .br .RI "Opaque network manager handle (shared cookie jar + event queue)\&. " .ti -1c .RI "typedef struct bark_ws \fBbark_ws_t\fP" .br .RI "Opaque WebSocket connection handle\&. " .ti -1c .RI "typedef enum \fBbark_ws_state\fP \fBbark_ws_state_t\fP" .br .RI "Lifecycle states of a WebSocket connection\&. " .ti -1c .RI "typedef struct \fBbark_net_cbs\fP \fBbark_net_cbs_t\fP" .br .RI "Main-thread network event callbacks dispatched by \fBbark_net_poll()\fP\&. " .ti -1c .RI "typedef void(* \fBbark_http_resp_fn\fP) (void *user, int status, const uint8_t *body, size_t len, const char *content_type)" .br .RI "Per-request HTTP response callback dispatched on the main thread inside \fBbark_net_poll()\fP\&. " .ti -1c .RI "typedef int(* \fBbark_http_chunk_fn\fP) (void *user, const uint8_t *data, size_t len, uint64_t received, uint64_t total)" .br .RI "Streaming download chunk callback; return non-zero to abort with \fBBARK_ERR_CANCELED\fP\&. " .ti -1c .RI "typedef int(* \fBbark_http_cancel_fn\fP) (void *user)" .br .RI "Cooperative cancellation probe polled during \fBbark_http_download()\fP\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBbark_ws_state\fP { \fBBARK_WS_CLOSED\fP = 0, \fBBARK_WS_CONNECTING\fP = 1, \fBBARK_WS_OPEN\fP = 2, \fBBARK_WS_CLOSING\fP = 3 }" .br .RI "Lifecycle states of a WebSocket connection\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBbark_net_t\fP * \fBbark_net_create\fP (const \fBbark_net_cbs_t\fP *cbs, void *user)" .br .RI "Create a network manager handle\&. " .ti -1c .RI "int \fBbark_net_poll\fP (\fBbark_net_t\fP *net, int timeout_ms)" .br .RI "Pump network I/O and dispatch completed HTTP and WebSocket callbacks\&. " .ti -1c .RI "void \fBbark_net_destroy\fP (\fBbark_net_t\fP *net)" .br .RI "Destroy a network manager handle and close active connections\&. " .ti -1c .RI "\fBbark_ws_t\fP * \fBbark_ws_open\fP (\fBbark_net_t\fP *net, const char *url, const char *cookie_opt)" .br .RI "Open a \fRws://\fP or \fRwss://\fP WebSocket connection (with optional Cookie header)\&. " .ti -1c .RI "int \fBbark_ws_send_text\fP (\fBbark_ws_t\fP *ws, const char *text, size_t len)" .br .RI "Send a UTF-8 text frame over an open WebSocket\&. " .ti -1c .RI "int \fBbark_ws_send_bin\fP (\fBbark_ws_t\fP *ws, const uint8_t *bytes, size_t len)" .br .RI "Send a binary frame over an open WebSocket\&. " .ti -1c .RI "int \fBbark_ws_status\fP (const \fBbark_ws_t\fP *ws)" .br .RI "Query the current \fBbark_ws_state_t\fP of \fRws\fP\&. " .ti -1c .RI "void \fBbark_ws_close\fP (\fBbark_ws_t\fP *ws, int code, const char *reason)" .br .RI "Initiate a graceful WebSocket close with \fRcode\fP and optional \fRreason\fP\&. " .ti -1c .RI "int \fBbark_http_get\fP (\fBbark_net_t\fP *net, uint32_t req_id, const char *url, const char *headers_nl)" .br .RI "Issue an asynchronous HTTP(S) GET; response is delivered to \fRon_http_resp\fP with \fRreq_id\fP\&. " .ti -1c .RI "int \fBbark_http_post\fP (\fBbark_net_t\fP *net, uint32_t req_id, const char *url, const char *headers_nl, const uint8_t *body, size_t len)" .br .RI "Issue an asynchronous HTTP(S) POST; response is delivered to \fRon_http_resp\fP with \fRreq_id\fP\&. " .ti -1c .RI "int \fBbark_http_get_cb\fP (\fBbark_net_t\fP *net, const char *url, const char *headers_nl, \fBbark_http_resp_fn\fP on_resp, void *user)" .br .RI "Issue an asynchronous HTTP(S) GET with a dedicated per-request callback\&. " .ti -1c .RI "int \fBbark_http_post_cb\fP (\fBbark_net_t\fP *net, const char *url, const char *headers_nl, const uint8_t *body, size_t len, \fBbark_http_resp_fn\fP on_resp, void *user)" .br .RI "Issue an asynchronous HTTP(S) POST with a dedicated per-request callback\&. " .ti -1c .RI "int \fBbark_http_download\fP (const char *url, \fBbark_http_chunk_fn\fP on_chunk, \fBbark_http_cancel_fn\fP should_cancel, void *user, int follow_redirects, int *status_out)" .br .RI "Blocking, cancellable streaming HTTP(S) GET (intended for background worker threads)\&. " .in -1c .SH "Detailed Description" .PP Bark asynchronous HTTPS and WebSocket client primitives\&. Headless HTTP(S) client and multi-instance RFC 6455 WebSocket API\&. .PP All asynchronous callbacks fire exclusively on the main thread inside \fBbark_net_poll()\fP\&. Works identically on native hosts (libcurl/OpenSSL) and browser WASM (fetch/WebSocket)\&. .SH "Enumeration Type Documentation" .PP .SS "enum \fBbark_ws_state\fP" .PP Lifecycle states of a WebSocket connection\&. .PP \fBEnumerator\fP .in +1c .TP \f(BIBARK_WS_CLOSED \fP Socket is closed\&. .TP \f(BIBARK_WS_CONNECTING \fP TLS/HTTP upgrade handshake in progress\&. .TP \f(BIBARK_WS_OPEN \fP Connected and ready to send/receive frames\&. .TP \f(BIBARK_WS_CLOSING \fP Close handshake in progress\&. .SH "Function Documentation" .PP .SS "int bark_http_download (const char * url, \fBbark_http_chunk_fn\fP on_chunk, \fBbark_http_cancel_fn\fP should_cancel, void * user, int follow_redirects, int * status_out)" .PP Blocking, cancellable streaming HTTP(S) GET (intended for background worker threads)\&. Ideal for large asset or model downloads\&. Returning non-zero from \fRon_chunk\fP or \fRshould_cancel\fP aborts the transfer with \fBBARK_ERR_CANCELED\fP\&. .SH "Author" .PP Generated automatically by Doxygen for Bark from the source code\&.