Skip to content

Commit

Permalink
Wait before closing socket on fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
Raicuparta committed Aug 11, 2020
1 parent 672c04c commit 566e459
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions OWML.Logging/ModSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
using OWML.Common;

Expand All @@ -10,6 +11,7 @@ namespace OWML.Logging
public class ModSocket : IModSocket
{
private readonly Socket _socket;
private const int _closeWaitSeconds = 1;

public ModSocket(int port)
{
Expand All @@ -32,6 +34,7 @@ public void WriteToSocket(IModSocketMessage message)

public void Close()
{
Thread.Sleep(TimeSpan.FromSeconds(_closeWaitSeconds));
_socket.Close();
}
}
Expand Down

0 comments on commit 566e459

Please sign in to comment.