diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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; +} |