mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-27 03:08:15 +02:00
Improved ReleaseSocket implementation
This commit is contained in:
parent
b6280748c1
commit
3674fcd58a
1 changed files with 4 additions and 5 deletions
|
@ -34,7 +34,7 @@ namespace Utilities
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public static void ReleaseSocket(Socket socket)
|
public static void ReleaseSocket(Socket socket)
|
||||||
{
|
{
|
||||||
|
@ -52,12 +52,11 @@ namespace Utilities
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (SocketException)
|
catch (SocketException)
|
||||||
{ }
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Closing socket closes the connection, and Close is a wrapper-method around Dispose.
|
||||||
socket.Close();
|
socket.Close();
|
||||||
socket = null;
|
|
||||||
GC.Collect();
|
|
||||||
GC.WaitForPendingFinalizers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue