aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-10-28 00:48:14 +0100
committerubq323 <ubq323@ubq323.website>2022-10-28 00:49:31 +0100
commit7a17c3a4ea869a04041ff2568fd02ec676ab8dff (patch)
treea2ff40bfcae165d294344adcb941d03b535b7f90 /util.c
parent705db03ebffa24b993f72ca2694ba0982fa80bde (diff)
large refactor continues
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..c545724
--- /dev/null
+++ b/util.c
@@ -0,0 +1,17 @@
+#include "util.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+ssize_t sendall(int sockfd, void *buf, size_t len) {
+ ssize_t total_sent = 0;
+ ssize_t sent;
+ do {
+ if ((sent = send(sockfd, buf+total_sent, len-total_sent, 0)) == -1) {
+ return -1;
+ }
+ total_sent += sent;
+ } while (total_sent < len);
+ DPn("SEND",buf,len);
+ return total_sent;
+}