#ifndef SLEELA_NET_H #define SLEELA_NET_H #include #include #ifdef __cplusplus extern "C" { #endif typedef enum { SL_NET_AUTO = 0, SL_NET_LINUX = 1, SL_NET_WINDOWS = 2, SL_NET_MACOS = 3 } SLNetPlatform; typedef intptr_t SLNetHandle; typedef ptrdiff_t SLNetCount; #define SL_NET_INVALID ((SLNetHandle)-1) SLNetPlatform slnet_platform(void); const char* slnet_platform_name(void); int slnet_platform_is_available(SLNetPlatform platform); /* TCP lifecycle. Handles are SLeeLa-owned opaque values, never raw SOCKETs. */ int slnet_startup(void); void slnet_shutdown(void); SLNetHandle slnet_listen(uint16_t port, int backlog); /* Host-specific listener; NULL host means wildcard (legacy slnet_listen remains unchanged). */ SLNetHandle slnet_listen_on(const char* host, uint16_t port, int backlog); /* Per-operation socket inactivity timeouts, milliseconds; zero is invalid. */ int slnet_set_timeouts(SLNetHandle handle, uint32_t receive_ms, uint32_t send_ms); SLNetHandle slnet_accept(SLNetHandle listener); SLNetHandle slnet_connect(const char* host, uint16_t port); SLNetCount slnet_read(SLNetHandle handle, char* buffer, size_t capacity); SLNetCount slnet_write(SLNetHandle handle, const char* data, size_t length); int slnet_close(SLNetHandle handle); /* Socket-handle validity and error normalization. */ int slnet_valid(SLNetHandle handle); int slnet_last_error(void); #ifdef __cplusplus } #endif #endif /* SLEELA_NET_H */