Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion kcp2k/Assets/kcp2k/MirrorTransport/KcpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class KcpTransport : Transport
// common
[Header("Transport Configuration")]
public ushort Port = 7777;
public IPAddress LocalIP = IPAddress.IPv6Any;
[Tooltip("NoDelay is recommended to reduce latency. This also scales better without buffers getting full.")]
public bool NoDelay = true;
[Tooltip("KCP internal update interval. 100ms is KCP default, but a lower interval is recommended to minimize latency and to scale to more networked entities.")]
Expand Down Expand Up @@ -148,7 +149,7 @@ public override Uri ServerUri()
return builder.Uri;
}
public override bool ServerActive() => server.IsActive();
public override void ServerStart() => server.Start(Port);
public override void ServerStart() => server.Start(Port, LocalIP);
public override void ServerSend(int connectionId, int channelId, ArraySegment<byte> segment)
{
// switch to kcp channel.
Expand Down
4 changes: 2 additions & 2 deletions kcp2k/Assets/kcp2k/highlevel/KcpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public KcpServer(Action<int> OnConnected,

public bool IsActive() => socket != null;

public void Start(ushort port)
public void Start(ushort port, IPAddress address = null)
{
// only start once
if (socket != null)
Expand All @@ -94,7 +94,7 @@ public void Start(ushort port)
#else
socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
socket.DualMode = true;
socket.Bind(new IPEndPoint(IPAddress.IPv6Any, port));
socket.Bind(new IPEndPoint(address ?? IPAddress.IPv6Any, port));
#endif
}

Expand Down