Skip to content

Commit f299c9e

Browse files
Updated to revised solution for NetSocket
Better compatibility for the NetSocket Ttl property for Nintendo Switch projects as revised by RevenantX.
1 parent 1fade5b commit f299c9e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

LiteNetLib/NetSocket.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,22 @@ public short Ttl
8585
{
8686
get
8787
{
88+
#if UNITY_SWITCH
89+
return 0;
90+
#else
8891
if (_udpSocketv4.AddressFamily == AddressFamily.InterNetworkV6)
8992
return (short)_udpSocketv4.GetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.HopLimit);
9093
return _udpSocketv4.Ttl;
94+
#endif
9195
}
9296
set
9397
{
98+
#if !UNITY_SWITCH
9499
if (_udpSocketv4.AddressFamily == AddressFamily.InterNetworkV6)
95100
_udpSocketv4.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.HopLimit, value);
96101
else
97102
_udpSocketv4.Ttl = value;
103+
#endif
98104
}
99105
}
100106

@@ -280,9 +286,8 @@ private bool BindSocket(Socket socket, IPEndPoint ep, bool reuseAddress, IPv6Mod
280286
}
281287
if (socket.AddressFamily == AddressFamily.InterNetwork)
282288
{
283-
#if !UNITY_SWITCH
284289
Ttl = NetConstants.SocketTTL;
285-
#endif
290+
286291
#if NETSTANDARD || NETCOREAPP
287292
if(!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
288293
#endif

0 commit comments

Comments
 (0)