]> git.lizzy.rs Git - dragonnet.git/blob - recv.c
Use getaddrinfo and getnameinfo for address parsing
[dragonnet.git] / recv.c
1 #include <dragonnet/recv.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <sys/socket.h>
6 #include <sys/types.h>
7 #include <unistd.h>
8
9 bool dragonnet_recv_raw(DragonnetPeer *p, void *buf, size_t n)
10 {
11         if (n == 0)
12                 return true;
13
14         ssize_t len = recv(p->sock, buf, n, MSG_WAITALL);
15         if (len < 0) {
16                 perror("recv");
17                 exit(EXIT_FAILURE);
18         }
19
20         return len != 0;
21 }