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

Failed to send packet: System.Net.Sockets.SocketException #130

Open tolstenko opened 5 years ago

tolstenko commented 5 years ago

I am facing this issue:

Socket bound to 0.0.0.0:63658: True
Network thread started
InitiatedConnect: user called connect
Failed to send packet: System.Net.Sockets.SocketException (0x80004005): An address incompatible with the requested protocol was used
   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 D:\projects\lidgren-network-gen3\Lidgren.Network\NetPeer.LatencySimulation.cs:line 164

Dns.GetHostEntry also returns IPv6 addresses. In this case, the IPv6 address (::1) is first in the list.

Steps to reproduce:

  1. download latest codebase
  2. open any example. in my case, I tested the chat client / server
  3. run and fail

Probably this could be caused by having many vEthernets on my machine and wifi.

kaholau commented 4 years ago

I also have the same issue. You can either change the targeting master server ip address to 127.0.0.1 in both MSServer and MSClient or change the default local address of Master Server to m_localAddress = IPAddress.IPv6Any or change the localhost solver in you OS to 127.0.0.1.

PJB3005 commented 4 years ago

Should probably make NetPeer.Connect(string host,...) overloads select IP based on currently configured address family.