mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 22:48:42 +00:00
removed unsafe
This commit is contained in:
@@ -156,12 +156,18 @@ namespace Esiur.Net.Sockets
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
Close();
|
||||
var ws = sock;
|
||||
|
||||
Close(); // best-effort graceful close handshake (fire-and-forget)
|
||||
|
||||
receiveNetworkBuffer = null;
|
||||
Receiver = null;
|
||||
|
||||
sock = null;
|
||||
|
||||
// Dispose the WebSocket so its buffers and handle are released; Close() only
|
||||
// starts the async close handshake and never disposes.
|
||||
try { ws?.Dispose(); } catch { }
|
||||
|
||||
OnDestroy?.Invoke(this);
|
||||
OnDestroy = null;
|
||||
}
|
||||
|
||||
@@ -458,6 +458,14 @@ public class SSLSocket : ISocket
|
||||
public void Destroy()
|
||||
{
|
||||
Close();
|
||||
|
||||
// Release the TLS stream and the underlying socket handle. NetworkStream(sock) does
|
||||
// not own the socket, so disposing the stream alone would leak the socket — dispose
|
||||
// both explicitly. Guarded because teardown may race with in-flight I/O callbacks.
|
||||
try { ssl?.Dispose(); } catch { }
|
||||
try { sock?.Close(); } catch { }
|
||||
try { sock?.Dispose(); } catch { }
|
||||
|
||||
Receiver = null;
|
||||
receiveNetworkBuffer = null;
|
||||
OnDestroy?.Invoke(this);
|
||||
|
||||
Reference in New Issue
Block a user