Skip to content

Commit

Permalink
potentially fix certain SocketExceptions on the UDP socket on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
compujuckel committed Nov 29, 2023
1 parent 444bf41 commit 995e3d0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion AssettoServer/Network/Udp/ACUdpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ public ACUdpServer(SessionManager sessionManager,
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
Log.Information("Starting UDP server on port {Port}", _port);


// https://stackoverflow.com/questions/5199026/c-sharp-async-udp-listener-socketexception
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
_socket.IOControl(-1744830452 /* SIO_UDP_CONNRESET */, new byte[] { 0, 0, 0, 0 }, null);
}

_socket.Bind(new IPEndPoint(IPAddress.Any, _port));
await Task.Factory.StartNew(() => ReceiveLoop(stoppingToken), TaskCreationOptions.LongRunning);
}
Expand Down

0 comments on commit 995e3d0

Please sign in to comment.