DWORD error = 0;
#if DEBUG_NETWORK
- LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_NETWORK_socket_close", "Closing 0x%x\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing 0x%x\n",
desc->fd);
#endif
SetLastError (0);
error = WSAGetLastError ();
SetErrnoFromWinsockError (error);
#if DEBUG_NETWORK
- LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_NETWORK_socket_close",
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Closed 0x%x, closesocket() returned %d, GLE is %u\n", desc->fd, ret,
error);
#endif
* @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));
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
{