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

Implement IPv6 Dual Mode #33

Closed queezle42 closed 3 years ago

queezle42 commented 9 years ago

Implements IPv6 Dual Mode as described in https://github.com/lidgren/lidgren-network-gen3/issues/32

My Visual Studio defaults use spaces instead of tabs. If you have an easy way to fix the affected lines please do so, otherwise I will fix that and create a new pull request.

Addramer commented 8 years ago

Hmm i know this is a very old topic, but i think there is an error in your changes, in Lidgren.Network/NetUtility.cs:190 you are adding the condition "ipAddress.AddressFamily == AddressFamily.InterNetworkV6" but it should be "address.AddressFamily == AddressFamily.InterNetworkV6" as you are iterating over "addresses". I have corrected this on my personnal copy of the library, and it works.

SteveProXNA commented 8 years ago

@Addramer - I saw this error also and modified in my local copy

SteveProXNA commented 8 years ago

Also, to add to previous entry, NetUtility:`140 should be ipCurrent.AddressFamily == AddressFamily.InterNetworkV6 NOT ipAddress - most likely from copy + paste.

SteveProXNA commented 7 years ago

Another entry: if you integrate the code into a game engine like Unity then you have to fork code on the client that connects to the server either over IPv4 or IPv6; i.e. you cannot integrate the "IPv6 Dual Mode" code into Lidgren as this requires .NET 4.5 and Unity is based off Mono .NET 3.5.

Also, when deploying to an iOS device using Unity 4.7.2 - the code will work OK if you choose scripting backend Mono but when you change to IL2CPP (recommended to support 64-bit architecture) then socket.ReceiveFrom() method will not hydrate the senderRemote IPEndpoint correctly.

This is a known issue [https://forum.unity3d.com/threads/unity3d-crashes-and-network-problem-with-ipv6.415604] As per this thread a patch is required i.e. Unity 4.7.2p1 - at the time of this writing, the patch is not currently available in Unity archives but Unity may send you a download link privately if you request it and the patch should resolve the socket issue accordingly.

SteveProXNA commented 7 years ago

Finally, I have documented the above on my blog: "Unity3D and IPv6-only Networking using Lidgren" http://steveproxna.blogspot.co.uk/2016/11/unity3d-and-ipv6-networking.html

I have referenced source code from my Github account that simulates a typical client / server networked game in IPv4-only with Lidgren code from master branch and compared the IPv6 implementation using Dual Mode pull request found here.

Source code: IPv4 https://github.com/SteveProXNA/UnityLidgrenIPv6/tree/master/IPv4 IPv6 https://github.com/SteveProXNA/UnityLidgrenIPv6/tree/master/IPv6

RevoluPowered commented 6 years ago

@SteveProXNA can you possibly send this pull request to my repo?

I've been patching some bugs with Lidgren.

captkirk88 commented 5 years ago

@lidgren Sorry to nudge you but could we get this merged?

lidgren commented 5 years ago

There's conflicting files and I'd love to see a solution that avoids creating a new heap object every time a packet is sent (yes, the library is pretty allocation heavy already, but i'd hate to add to it)

PJB3005 commented 4 years ago

Superseded by #136