-GArik: fix typo
[oweals/gnunet.git] / src / util / network.c
index c4861ecfadaea299fbc49784db7ebe979c82b1a0..fb8744af186aa4662ae14cc1c724ec7035b54e4f 100644 (file)
@@ -377,13 +377,20 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
  * @return NULL on error (including not supported on target platform)
  */
 struct GNUNET_NETWORK_Handle *
-GNUNET_NETWORK_socket_box_native (int fd)
+GNUNET_NETWORK_socket_box_native (SOCKTYPE fd)
 {
+  struct GNUNET_NETWORK_Handle *ret;
 #if MINGW
-  return NULL;
+  unsigned long i;
+  DWORD d;
+  /* FIXME: Find a better call to check that FD is valid */
+  if (WSAIoctl (fd, FIONBIO, (void *) &i, sizeof (i), NULL, 0, &d, NULL, NULL) != 0)
+    return NULL;                /* invalid FD */
+  ret = GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle));
+  ret->fd = fd;
+  ret->af = AF_UNSPEC;
+  return ret;
 #else
-  struct GNUNET_NETWORK_Handle *ret;
-
   if (fcntl (fd, F_GETFD) < 0)
     return NULL;                /* invalid FD */
   ret = GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle));
@@ -1312,12 +1319,15 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
             handle_array[nhandles++] = fh->oOverlapRead->hEvent;
             readArray[readPipes++] = fh;
           }
-          /*
-           * else
-           * {
-           * SetErrnoFromWinError (error_code);
-           * }
-           */
+          else
+          {
+#if DEBUG_NETWORK
+            LOG (GNUNET_ERROR_TYPE_DEBUG,
+                 "Read failed, adding the read ready event to the array as %d\n", nhandles);
+#endif
+            handle_array[nhandles++] = hEventReadReady;
+            readArray[readPipes++] = fh;
+          }
         }
         else
         {