-/*
- * w32socket-unix.c: Unix specific socket code.
+/**
+ * \file
+ * Unix specific socket code.
*
* Copyright 2016 Microsoft
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <errno.h>
#include <fcntl.h>
-#include <sys/types.h>
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif
gint
mono_w32socket_set_blocking (SOCKET socket, gboolean blocking)
{
+#ifdef O_NONBLOCK
gint ret;
gpointer handle;
return SOCKET_ERROR;
}
-#ifdef O_NONBLOCK
/* This works better than ioctl(...FIONBIO...)
* on Linux (it causes connect to return
* EINPROGRESS, but the ioctl doesn't seem to) */
ret = fcntl (socket, F_GETFL, 0);
if (ret != -1)
ret = fcntl (socket, F_SETFL, blocking ? (ret & (~O_NONBLOCK)) : (ret | (O_NONBLOCK)));
-#endif /* O_NONBLOCK */
if (ret == -1) {
gint errnum = errno;
}
return 0;
+#else
+ mono_w32socket_set_last_error (ERROR_NOT_SUPPORTED);
+ return SOCKET_ERROR;
+#endif /* O_NONBLOCK */
}
gint
case ENETDOWN: return WSAENETDOWN;
#endif
case ENODEV: return WSAENETDOWN;
+#ifdef EPROTOTYPE
+ case EPROTOTYPE: return WSAEPROTOTYPE;
+#endif
+#ifdef ENXIO
+ case ENXIO: return WSAENXIO;
+#endif
default:
g_error ("%s: no translation into winsock error for (%d) \"%s\"", __func__, error, g_strerror (error));
}
}
gboolean
-ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError *error)
{
+ error_init (error);
#if defined (SO_REUSEPORT)
return TRUE;
#else