summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/test/src/crypto/tls/test/TlsServerTest.cs21
1 files changed, 14 insertions, 7 deletions
diff --git a/crypto/test/src/crypto/tls/test/TlsServerTest.cs b/crypto/test/src/crypto/tls/test/TlsServerTest.cs
index 77adf22f7..7920cb59a 100644
--- a/crypto/test/src/crypto/tls/test/TlsServerTest.cs
+++ b/crypto/test/src/crypto/tls/test/TlsServerTest.cs
@@ -26,14 +26,21 @@ namespace Org.BouncyCastle.Crypto.Tls.Tests
             TcpListener ss = new TcpListener(IPAddress.Any, port);
             ss.Start();
             Stream stdout = Console.OpenStandardOutput();
-            while (true)
+            try
             {
-                TcpClient s = ss.AcceptTcpClient();
-                Console.WriteLine("--------------------------------------------------------------------------------");
-                Console.WriteLine("Accepted " + s);
-                ServerThread st = new ServerThread(s, stdout);
-                Thread t = new Thread(new ThreadStart(st.Run));
-                t.Start();
+                while (true)
+                {
+                    TcpClient s = ss.AcceptTcpClient();
+                    Console.WriteLine("--------------------------------------------------------------------------------");
+                    Console.WriteLine("Accepted " + s);
+                    ServerThread st = new ServerThread(s, stdout);
+                    Thread t = new Thread(new ThreadStart(st.Run));
+                    t.Start();
+                }
+            }
+            finally
+            {
+                ss.Stop();
             }
         }