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

Switch does not support ipv6 #14

Merged
merged 4 commits into from
Jan 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions kcp2k/Assets/kcp2k/highlevel/KcpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ public class KcpServer

// state
Socket socket;
#if UNITY_SWITCH
miwarnec marked this conversation as resolved.
Show resolved Hide resolved
EndPoint newClientEP = new IPEndPoint(IPAddress.Any, 0);
#else
EndPoint newClientEP = new IPEndPoint(IPAddress.IPv6Any, 0);
#endif
// IMPORTANT: raw receive buffer always needs to be of 'MTU' size, even
// if MaxMessageSize is larger. kcp always sends in MTU
// segments and having a buffer smaller than MTU would
Expand Down Expand Up @@ -82,13 +86,15 @@ public void Start(ushort port)
}

// listen
#if UNITY_SWITCH
// Switch does not support ipv6
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, port));
#else
socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
// dual mode where available.
// (not available on nintendo switch, where it throws errors)
#if !UNITY_SWITCH
socket.DualMode = true;
#endif
socket.Bind(new IPEndPoint(IPAddress.IPv6Any, port));
#endif
}

public void Send(int connectionId, ArraySegment<byte> segment, KcpChannel channel)
Expand Down