fix MinGW, more precise type/error code handling
authorNils Durner <durner@gnunet.org>
Sat, 13 Feb 2010 23:25:06 +0000 (23:25 +0000)
committerNils Durner <durner@gnunet.org>
Sat, 13 Feb 2010 23:25:06 +0000 (23:25 +0000)
src/util/network.c

index 4f652a52fc66661da80338e2419bf77d676bc86d..e7a276422a0554e513dc0dc934b987ba6f35fbcd 100644 (file)
 
 struct GNUNET_NETWORK_Handle
 {
+#ifndef MINGW
   int fd;
+#else
+  SOCKET fd;
+#endif
 };
 
 
@@ -57,7 +61,7 @@ struct GNUNET_NETWORK_FDSet
 
 #ifdef WINDOWS
   /**
-   * Linked list of handles 
+   * Linked list of handles
    */
   struct GNUNET_CONTAINER_SList *handles;
 #endif
@@ -368,12 +372,16 @@ GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle
   int pending;
 
   /* How much is there to be read? */
+#ifndef WINDOWS
   error = ioctl (desc->fd, FIONREAD, &pending);
-
   if (error == 0)
+#else
+  error = ioctlsocket (desc->fd, FIONREAD, &pending);
+  if (error != SOCKET_ERROR)
+#endif
     return pending;
   else
-    return error;
+    return GNUNET_NO;
 }
 
 /**