Skip to content

Commit

Permalink
Update Udp.cs
Browse files Browse the repository at this point in the history
Support for communication with IPv6 addresses
  • Loading branch information
nmchan committed May 5, 2021
1 parent 95f1987 commit 1471645
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Assets/uOSC/Scripts/Core/DotNet/Udp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public override void StartServer(int port)
Stop();
state_ = State.Server;

endPoint_ = new IPEndPoint(IPAddress.Any, port);
udpClient_ = new UdpClient(endPoint_);
endPoint_ = new IPEndPoint(IPAddress.IPv6Any, port);
udpClient_ = new UdpClient(System.Net.Sockets.AddressFamily.InterNetworkV6);
udpClient_.Client.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IPv6, System.Net.Sockets.SocketOptionName.IPv6Only, 0);
udpClient_.Client.Bind(endPoint_);
thread_.Start(() =>
{
while (udpClient_.Available > 0)
Expand All @@ -57,7 +59,7 @@ public override void StartClient(string address, int port)

var ip = IPAddress.Parse(address);
endPoint_ = new IPEndPoint(ip, port);
udpClient_ = new UdpClient();
udpClient_ = new UdpClient(endPoint_.AddressFamily);
}

public override void Stop()
Expand Down

0 comments on commit 1471645

Please sign in to comment.