lidgren / lidgren-network-gen3

Lidgren Network Library
https://groups.google.com/forum/#!forum/lidgren-network-gen3
MIT License
1.19k stars 331 forks source link

System.Net.Sockets.SocketException #89

Open se5a opened 6 years ago

se5a commented 6 years ago

I get a

System.Net.Sockets.SocketException
The descriptor is not a socket

when I Start(); on a NetPeer object. this only happens while running debug, and if I continue it continues to run fine. however it's a pain when I'm attempting to debug something and having to continue the process whenever I start a server or client.

I'm not sure why the exception is getting hit.

debugging with monodevelop 7.1 on linux mint.

mattj1 commented 6 years ago

Not sure if this is the same issue, but I get the following crash information when calling Start()

mono_w32socket_convert_error: no translation into winsock error for (6) "Device not configured" Stacktrace:

at <0xffffffff> at (wrapper managed-to-native) System.Net.Sockets.Socket.IOControl_internal (intptr,int,byte[],byte[],int&) [0x0000c] in :0 at System.Net.Sockets.Socket.IOControl_internal (System.Net.Sockets.SafeSocketHandle,int,byte[],byte[],int&) [0x0000a] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/Socket.cs:2491 at System.Net.Sockets.Socket.IOControl (int,byte[],byte[]) [0x00019] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/Socket.cs:2476 at Lidgren.Network.NetPeer.BindSocket (bool) [0x000fd] in /Users/matt/projects/test2xna/Lidgren/Lidgren.Network/NetPeer.Internal.cs:137 at Lidgren.Network.NetPeer.InitializeNetwork () [0x0007c] in /Users/matt/projects/test2xna/Lidgren/Lidgren.Network/NetPeer.Internal.cs:168 at Lidgren.Network.NetPeer.Start () [0x0006a] in /Users/matt/projects/test2xna/Lidgren/Lidgren.Network/NetPeer.cs:150

mattj1 commented 6 years ago

I should mention that I avoid the crash by simply commenting out the following line:

m_socket.IOControl((int)SIO_UDP_CONNRESET, new byte[] { Convert.ToByte(false) }, null);

This is on OSX, by the way.

se5a commented 6 years ago

@mattj1 you'll get an exception if you try to start up on a device that has no network connections - found this out while on a plane in flight mode, that's not what you're seeing here is it? I'm not sure that yours is the same problem as what I originally posted.

I've tried debugging in windows with VS and I don't get the problem there. I guess it's possible its a mono bug. I'm not sure. it's kind of annoying since I have to tell whatever it is I'm running to continue whatever I'm testing network related stuff in linux.

GabrielJadderson commented 6 years ago

yeah can confirm, having this issue too. Only happens in Debug mode because of the "DEBUG" preprocessor directive in LatencySimulation.cs, there are no issues in release mode and works fine.

Failed to send packet: System.Net.Sockets.SocketException (0x80004005): A socket operation was attempted to an unreachable network at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP) at Lidgren.Network.NetPeer.ActuallySendPacket(Byte[] data, Int32 numBytes, IPEndPoint target, Boolean& connectionReset) in C:\Users\lidgren-network-gen3-master\Lidgren.Network\NetPeer.LatencySimulation.cs:line 153