diff options
Diffstat (limited to 'server/main.c')
| -rw-r--r-- | server/main.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/server/main.c b/server/main.c index 789d392..6a5e5ba 100644 --- a/server/main.c +++ b/server/main.c @@ -1,12 +1,11 @@ #include <stdio.h> #include <stdlib.h> -#include <err.h> -#include <sys/socket.h> -#include <unistd.h> -#include <netinet/in.h> #include <time.h> +#include "net_compat.h" int main() { + net_init(); + int fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) @@ -22,6 +21,8 @@ int main() { err(EXIT_FAILURE, "bind failed"); } + set_nonblocking(fd); + time_t startTime = time(NULL); while (time(NULL) < startTime + 60) { @@ -29,13 +30,15 @@ int main() { socklen_t connectionLen = sizeof(connection); char buff[64]; - int size = recvfrom(fd, buff, sizeof(buff), MSG_DONTWAIT, + int size = recvfrom(fd, buff, sizeof(buff), 0, (struct sockaddr *)&connection, &connectionLen); if (size != -1) - printf("got a message\n"); + printf("message recievd\n"); } close(fd); + net_cleanup(); + return 0; } |