adapt to linux
authorLaurent Mazet <mazet@softndesign.org>
Sat, 6 May 2023 09:54:07 +0000 (11:54 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Sat, 6 May 2023 09:54:07 +0000 (11:54 +0200)
webserver.c

index 5b438488b42d9e75e9823366d3b182bb13b65960..530f1aadf9aa46f9e8a98a54e231b661178ffa23 100644 (file)
@@ -9,8 +9,11 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #else /* Posix */
+#include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #endif
@@ -66,7 +69,7 @@ socket_t open_listening_socket (int port)
         return -1;
 #else /* Posix */
     socket_t sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
-    if (socket < 0)
+    if (sock < 0)
         return -1;
 #endif
 
@@ -88,7 +91,7 @@ socket_t open_listening_socket (int port)
             VERBOSE (ERROR, fprintf (stderr, "error: %d\n", WSAGetLastError ()));
         }
 #else /* Posix */
-    if (socket < 0) {
+    if (rc < 0) {
         VERBOSE (ERROR, fprintf (stderr, "error: %d\n", errno));
         close (sock);
 #endif