Add errno print on server failure

master
Nick Krichevsky 2018-09-09 19:51:51 -04:00
parent 28700e2e63
commit 5cca544e59
1 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
@ -17,6 +18,9 @@ int main(int argc, char* argv[]) {
printf("%s", PORT_ERROR); printf("%s", PORT_ERROR);
} }
struct server_info info = setup(port_num); struct server_info info = setup(port_num);
if (info.status == STATUS_ERROR) {
printf("%s\n", strerror(errno));
}
serve_one_request(info.sock_fd); serve_one_request(info.sock_fd);
shutdown(info.sock_fd, SHUT_RDWR); shutdown(info.sock_fd, SHUT_RDWR);
close(info.sock_fd); close(info.sock_fd);