feat: add C & Zig bindings for socket

This commit is contained in:
CJ van den Berg 2026-03-02 19:02:50 +00:00
parent e19ff271d0
commit d1cb42d53c
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
11 changed files with 209 additions and 13 deletions

View file

@ -13,18 +13,20 @@ auto tcp_c_api(thespian::context &ctx, bool &result, thespian::env_t env)
(void)env;
struct thespian_tcp_acceptor_handle *a = thespian_tcp_acceptor_create("tag");
check(a != nullptr);
uint16_t port = thespian_tcp_acceptor_listen(a, in6addr_any, 0);
// port may be zero if something went wrong; ignore for smoke.
(void)port;
thespian_tcp_acceptor_close(a);
thespian_tcp_acceptor_destroy(a);
if (a != nullptr) {
uint16_t port = thespian_tcp_acceptor_listen(a, in6addr_any, 0);
// port may be zero if something went wrong; ignore for smoke.
(void)port;
thespian_tcp_acceptor_close(a);
thespian_tcp_acceptor_destroy(a);
}
struct thespian_tcp_connector_handle *c =
thespian_tcp_connector_create("tag");
check(c != nullptr);
// don't attempt to connect, simply exercise create/destroy
thespian_tcp_connector_destroy(c);
if (c != nullptr) {
// don't attempt to connect, simply exercise create/destroy
thespian_tcp_connector_destroy(c);
}
result = true;
return ok();