Skip to content

Commit

Permalink
Merge pull request #3 from artfulhacker/revert-2-artfulhacker-patch-1
Browse files Browse the repository at this point in the history
Revert "added RestartAfterListenError"
  • Loading branch information
Mike Olsen authored Aug 25, 2016
2 parents ad897f0 + ead5f7f commit 911b4be
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/Fleck/WebSocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public WebSocketServer(int port, string location)
public X509Certificate2 Certificate { get; set; }
public SslProtocols EnabledSslProtocols { get; set; }
public IEnumerable<string> SupportedSubProtocols { get; set; }
public bool RestartAfterListenError { get; set; }

public bool IsSecure
{
Expand Down Expand Up @@ -100,24 +99,7 @@ public void Start(Action<IWebSocketConnection> config)

private void ListenForClients()
{
ListenerSocket.Accept(OnClientConnect, e => {
+ FleckLog.Error("Listener socket is closed", e);
+ if(RestartAfterListenError){
+ FleckLog.Info("Listener socket restarting");
+ try
+ {
+ ListenerSocket.Dispose();
+ var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+ ListenerSocket = new SocketWrapper(socket);
+ Start(_config);
+ FleckLog.Info("Listener socket restarted");
+ }
+ catch (Exception ex)
+ {
+ FleckLog.Error("Listener could not be restarted", ex);
+ }
+ }
+ });
ListenerSocket.Accept(OnClientConnect, e => FleckLog.Error("Listener socket is closed", e));
}

private void OnClientConnect(ISocket clientSocket)
Expand Down

0 comments on commit 911b4be

Please sign in to comment.