From 0d9fa6b7e2ba45e3d953aa133e58ea73305e123b Mon Sep 17 00:00:00 2001 From: icedream Date: Thu, 22 May 2014 17:17:21 +0200 Subject: [PATCH] Mono doesn't support Windows-proprietary IP-fallback socket. --- src/libnpsharp/NP/NPServer.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libnpsharp/NP/NPServer.cs b/src/libnpsharp/NP/NPServer.cs index 751e61e..014995b 100644 --- a/src/libnpsharp/NP/NPServer.cs +++ b/src/libnpsharp/NP/NPServer.cs @@ -31,7 +31,13 @@ namespace NPSharp.NP _log = LogManager.GetLogger("NPServer"); _clients = new List(); - _socket = new Socket(SocketType.Stream, ProtocolType.IP); + // Mono can't compile this since the constructor is proprietary to Windows' .NET library + //_socket = new Socket(SocketType.Stream, ProtocolType.IP); + + // Instead we will specifically disable the socket's property to ignore IPv4 + _socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); + _socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0); + _port = port; }