{
ThrowIfDisposedAndClosed ();
- if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.ReuseAddress && optionValue != 0 && !SupportsPortReuse ())
+ if (optionLevel == SocketOptionLevel.Socket && optionName == SocketOptionName.ReuseAddress && optionValue != 0 && !SupportsPortReuse (protocol_type))
throw new SocketException ((int) SocketError.OperationNotSupported, "Operating system sockets do not support ReuseAddress.\nIf your socket is not intended to bind to the same address and port multiple times remove this option, otherwise you should ignore this exception inside a try catch and check that ReuseAddress is true before binding to the same address and port multiple times.");
int error;
internal static extern void cancel_blocking_socket_operation (Thread thread);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern bool SupportsPortReuse ();
+ internal static extern bool SupportsPortReuse (ProtocolType proto);
}
}
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 149;
+ private const int mono_corlib_version = 150;
#pragma warning restore 169
[ComVisible (true)]
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 149
+#define MONO_CORLIB_VERSION 150
typedef struct
{
}
gboolean
-ves_icall_System_Net_Sockets_Socket_SupportPortReuse (void)
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
{
#if defined (SO_REUSEPORT) || defined (HOST_WIN32)
- return TRUE;
+ return TRUE;
#else
- return FALSE;
+#ifdef __linux__
+ /* Linux always supports double binding for UDP, even on older kernels. */
+ if (proto == ProtocolType_Udp)
+ return TRUE;
+#endif
+ return FALSE;
#endif
}
extern void ves_icall_System_Net_Sockets_Socket_Disconnect_internal(SOCKET sock, MonoBoolean reuse, gint32 *error);
extern gboolean ves_icall_System_Net_Sockets_Socket_SendFile_internal (SOCKET sock, MonoString *filename, MonoArray *pre_buffer, MonoArray *post_buffer, gint flags);
void icall_cancel_blocking_socket_operation (MonoThread *thread);
-extern gboolean ves_icall_System_Net_Sockets_Socket_SupportPortReuse (void);
+extern gboolean ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto);
extern void mono_network_init(void);
extern void mono_network_cleanup(void);