refactor(socket): better naming convention

This commit is contained in:
2026-01-14 01:43:02 +01:00
parent 676268798b
commit f9d6975cce
2 changed files with 7 additions and 7 deletions

View File

@@ -4,8 +4,8 @@
#include <myclib/mystring.h> #include <myclib/mystring.h>
#include <sys/types.h> #include <sys/types.h>
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 #endif

View File

@@ -3,10 +3,10 @@
#include <errno.h> #include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
ssize_t cws_read_data(int sockfd, string_s *str) { size_t cws_socket_read(int sockfd, string_s *str) {
char tmp[4096] = {0}; 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 (n < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* No data available right now */ /* No data available right now */
@@ -26,9 +26,9 @@ ssize_t cws_read_data(int sockfd, string_s *str) {
return n; return n;
} }
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) {
ssize_t total_sent = 0; size_t total_sent = 0;
ssize_t n; size_t n;
while (total_sent < len) { while (total_sent < len) {
n = send(sockfd, buffer + total_sent, len - total_sent, flags); n = send(sockfd, buffer + total_sent, len - total_sent, flags);