From 0d8ea7407178fe85529ca5b56733635834e49f32 Mon Sep 17 00:00:00 2001 From: Federico Barresi Date: Thu, 7 May 2020 00:58:24 +0200 Subject: [PATCH] Check Connection on Socket close --- Sharp7/S7Client.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sharp7/S7Client.cs b/Sharp7/S7Client.cs index 06aea3a..be06749 100644 --- a/Sharp7/S7Client.cs +++ b/Sharp7/S7Client.cs @@ -723,7 +723,10 @@ namespace Sharp7 public int Disconnect() { - Socket.Close(); + if (Socket != null && Socket.Connected) + { + Socket.Close(); + } return 0; }