plc: implemented shutdown of the socket correctly (Issue #29).

Signed-off-by: Michele Cattafesta <michele.cattafesta@mesta-automation.com>
This commit is contained in:
Michele Cattafesta
2016-08-26 12:29:23 +02:00
parent 83e45e3be8
commit 78bb5ea1fa
2 changed files with 7 additions and 1 deletions

View File

@@ -143,11 +143,15 @@ namespace S7.Net
return response;
}
public void Shutdown(SocketShutdown how)
{
_socket.Shutdown(how);
}
public void Close()
{
if (_socket != null)
{
_socket.Shutdown(SocketShutdown.Both);
_socket.Dispose();
_socket = null;
}

View File

@@ -242,6 +242,7 @@ namespace S7.Net
{
if (_mSocket != null && _mSocket.Connected)
{
_mSocket.Shutdown(SocketShutdown.Both);
_mSocket.Close();
}
}
@@ -1096,6 +1097,7 @@ namespace S7.Net
if (_mSocket.Connected)
{
//Close() performs a Dispose on the socket.
_mSocket.Shutdown(SocketShutdown.Both);
_mSocket.Close();
}
//((IDisposable)_mSocket).Dispose();