fixed errors in sockets

This commit is contained in:
2026-03-02 17:53:19 +03:00
parent 56ee64dd78
commit b20e669d93
3 changed files with 40 additions and 18 deletions

View File

@@ -418,6 +418,8 @@ size_t sl_RB_writestr(sl_ringbuffer_t *b, char *s);
/******************************************************************************\
The original socket.h
\******************************************************************************/
// max length (including trailing '\0') of UNIX socket path
#define UNIX_SOCK_PATH_MAX 108
// handler result: what to send to client
typedef enum{
@@ -448,7 +450,7 @@ typedef struct{
// optional keyword number like key[12] = 500
typedef struct{
double magick; // Inf - to distinguish it from sl_sock_*_t
double magick; // -Inf - to distinguish it from sl_sock_*_t
int n; // if n < 0 there was no any number in `key`
} sl_sock_keyno_t;
#define SL_SOCK_KEYNO_DEFAULT (sl_sock_keyno_t){.magick = -INFINITY, .n = -1}
@@ -478,6 +480,9 @@ typedef enum{
struct sl_sock;
// opent socket and return its file descriptor
int sl_sock_getfd(sl_socktype_e type, const char *path);
// default max clients amount
#define SL_DEF_MAXCLIENTS (32)
// custom socket handlers: connect/disconnect/etc
@@ -545,4 +550,3 @@ int sl_sock_sendall(sl_sock_t *sock, uint8_t *data, size_t len);
sl_sock_hresult_e sl_sock_inthandler(sl_sock_t *client, sl_sock_hitem_t *hitem, const char *str);
sl_sock_hresult_e sl_sock_dblhandler(sl_sock_t *client, sl_sock_hitem_t *hitem, const char *str);
sl_sock_hresult_e sl_sock_strhandler(sl_sock_t *client, sl_sock_hitem_t *hitem, const char *str);