From 566e45950f5eef080c870ccadd6e5736c3c2db93 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Tue, 11 Aug 2020 19:56:08 +0200 Subject: [PATCH] Wait before closing socket on fatal error --- OWML.Logging/ModSocket.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OWML.Logging/ModSocket.cs b/OWML.Logging/ModSocket.cs index fb3330278..3311a43b1 100644 --- a/OWML.Logging/ModSocket.cs +++ b/OWML.Logging/ModSocket.cs @@ -2,6 +2,7 @@ using System.Net; using System.Net.Sockets; using System.Text; +using System.Threading; using Newtonsoft.Json; using OWML.Common; @@ -10,6 +11,7 @@ namespace OWML.Logging public class ModSocket : IModSocket { private readonly Socket _socket; + private const int _closeWaitSeconds = 1; public ModSocket(int port) { @@ -32,6 +34,7 @@ public void WriteToSocket(IModSocketMessage message) public void Close() { + Thread.Sleep(TimeSpan.FromSeconds(_closeWaitSeconds)); _socket.Close(); } }