hermes

HTTP GET/HEAD-only web server for static content.
git clone git://git.francescosaccone.com/hermes
Log | Files | Refs | README | LICENSE

commit 53b421b3a815b1a613c74e1f93b656085d58f78e
parent 7dbbba2d789b1fec099301413ba0473f10aff1e6
Author: Francesco Saccone <francesco@francescosaccone.com>
Date:   Mon, 31 Mar 2025 18:44:11 +0200

feat: add send_to_socket function

Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>

Diffstat:
Msocket.c | 9+++++++++
Msocket.h | 8++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/socket.c b/socket.c @@ -94,3 +94,12 @@ read_client_request(int client_socket_fd, return 0; } + +int +send_to_socket(int socket_fd, char *data) { + if (send(socket_fd, data, strlen(data), 0) == -1) { + return -1; + } + + return 0; +} diff --git a/socket.h b/socket.h @@ -42,4 +42,12 @@ read_client_request(int client_socket_fd, char *buffer, unsigned int buffer_size); +/* + * Writes data to a socket. + * + * Returns -1 in case of an error and 0 otherwise. + */ +int +send_to_socket(int socket_fd, char *data); + #endif