Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors with discovery when using IPv6 #150

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JimmyCushnie
Copy link

Previously if you called NetPeer.DiscoverLocalPeers() when the NetPeer is using IPv6, you'd get a SocketException about pointers in the wrong place. This fixes the bug by mapping the broadcast address to IPv6 when the peer is using IPv6.

CC @PJB3005, who originally wrote the IPv6 support in #136 .

@JimmyCushnie
Copy link
Author

There is a similar error when using DiscoverKnownPeer() in IPv4 if the known peer is an IPv6 address.

Lidgren: Failed to send packet: System.Net.Sockets.SocketException (0x80004005): An address incompatible with the requested protocol was used.

  at System.Net.Sockets.Socket.SendTo (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) [0x00082] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
  at Lidgren.Network.NetPeer.ActuallySendPacket (System.Byte[] data, System.Int32 numBytes, System.Net.IPEndPoint target, System.Boolean& connectionReset) [0x000a7] in C:\_Unity_Projects\_LogicWorld\Logic-World\Client\Assets\Lidgren\NetPeer.LatencySimulation.cs:164 </color>

I'm not sure how best to solve that one. The error message should be more helpful though.

@JimmyCushnie JimmyCushnie changed the title Fixed local discovery throwing an exception when using IPv6 Fixed errors with discovery when using IPv6 Jan 29, 2021
@JimmyCushnie
Copy link
Author

I was experiencing an issue in Unity where discovery requests could not be sent to IPv4 servers when the client is in IPv6 Dual-Stack. However, bizarrely, this error only occurred in built versions of the program; in the Unity editor there were no problems. Looking at the code I have no idea why it worked in the editor at all, as the IPv4 addresses were not being mapped to IPv6 in the Lidgren code.

Regardless, this PR now fixes the issue I described above.

EntenKoeniq added a commit to RAGECOOP/lidgren-network-gen3 that referenced this pull request Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant