Skip to content

Commit

Permalink
Added changes from Moka7 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherpard committed Sep 14, 2017
1 parent 41fee76 commit 73e65d8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/com/sourceforge/snap7/moka7/S7Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,32 @@ public int Connect()
}
}
Connected=LastError==0;

// In case the connection is not completely established (TCP connection + ISO connection + PDU negotiation)
// we close the socket and its IO streams to revert the object back to pre-Connect() state
if (!Connected)
{
if (TCPSocket != null) {
try {
TCPSocket.close();
} catch (IOException ex) {
}
}
if (InStream != null) {
try {
InStream.close();
} catch (IOException ex) {
}
}
if (OutStream != null) {
try {
OutStream.close();
} catch (IOException ex) {
}
}
_PDULength = 0;
}

return LastError;
}

Expand Down

0 comments on commit 73e65d8

Please sign in to comment.