From 771fc5809a54ea9b99e38151facfaa70938b96cf Mon Sep 17 00:00:00 2001 From: Martin Regen Date: Thu, 1 Sep 2016 12:38:49 +0200 Subject: [PATCH] fix exception during teardown of tcp listener --- Stack/Opc.Ua.Core/Stack/Tcp/TcpListener.cs | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Stack/Opc.Ua.Core/Stack/Tcp/TcpListener.cs b/Stack/Opc.Ua.Core/Stack/Tcp/TcpListener.cs index ba2c2174a3..d35e52c478 100644 --- a/Stack/Opc.Ua.Core/Stack/Tcp/TcpListener.cs +++ b/Stack/Opc.Ua.Core/Stack/Tcp/TcpListener.cs @@ -342,17 +342,20 @@ namespace Opc.Ua.Bindings e.Dispose(); - // go back and wait for the next connection. - try - { - e = new SocketAsyncEventArgs(); - e.Completed += OnAccept; - e.UserToken = listeningSocket; - listeningSocket.AcceptAsync(e); - } - catch (Exception ex) - { - Utils.Trace(ex, "Unexpected error listening for a new connection."); + if (e.SocketError != SocketError.OperationAborted) + { + // go back and wait for the next connection. + try + { + e = new SocketAsyncEventArgs(); + e.Completed += OnAccept; + e.UserToken = listeningSocket; + listeningSocket.AcceptAsync(e); + } + catch (Exception ex) + { + Utils.Trace(ex, "Unexpected error listening for a new connection."); + } } } }