Improved ReleaseSocket implementation

This commit is contained in:
Tal Aloni 2017-09-03 15:57:58 +03:00
parent b6280748c1
commit 3674fcd58a

View file

@ -34,7 +34,7 @@ namespace Utilities
}
/// <summary>
/// Socket will be forcefully closed, all pending data will be ignored, and socket will be deallocated.
/// Socket will be forcefully closed and all pending data will be ignored.
/// </summary>
public static void ReleaseSocket(Socket socket)
{
@ -52,12 +52,11 @@ namespace Utilities
return;
}
catch (SocketException)
{ }
{
}
}
// Closing socket closes the connection, and Close is a wrapper-method around Dispose.
socket.Close();
socket = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
}