From f9d6975cce9bb0dec8e758aaf98b153dde3c2d7f Mon Sep 17 00:00:00 2001 From: Francesco Date: Wed, 14 Jan 2026 01:43:02 +0100 Subject: [PATCH] refactor(socket): better naming convention --- include/core/socket.h | 4 ++-- src/core/socket.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/core/socket.h b/include/core/socket.h index 3335033..3a30343 100644 --- a/include/core/socket.h +++ b/include/core/socket.h @@ -4,8 +4,8 @@ #include #include -ssize_t cws_read_data(int sockfd, string_s *str); +size_t cws_socket_read(int sockfd, string_s *str); -ssize_t cws_send_data(int sockfd, char *buffer, int len, int flags); +size_t cws_socket_send(int sockfd, char *buffer, size_t len, int flags); #endif diff --git a/src/core/socket.c b/src/core/socket.c index 30c2e15..982d498 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -3,10 +3,10 @@ #include #include -ssize_t cws_read_data(int sockfd, string_s *str) { +size_t cws_socket_read(int sockfd, string_s *str) { char tmp[4096] = {0}; - ssize_t n = recv(sockfd, tmp, sizeof tmp, 0); + size_t n = recv(sockfd, tmp, sizeof tmp, 0); if (n < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) { /* No data available right now */ @@ -26,9 +26,9 @@ ssize_t cws_read_data(int sockfd, string_s *str) { return n; } -ssize_t cws_send_data(int sockfd, char *buffer, int len, int flags) { - ssize_t total_sent = 0; - ssize_t n; +size_t cws_socket_send(int sockfd, char *buffer, size_t len, int flags) { + size_t total_sent = 0; + size_t n; while (total_sent < len) { n = send(sockfd, buffer + total_sent, len - total_sent, flags);