Skip to content

Commit 63619fe

Browse files
committed
Close underlying socket if left outstanding in call to Create
1 parent 104b7ff commit 63619fe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cTlsSocket.cls

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ Private Const NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG As Long = &H2
160160
'--- errors
161161
Private Const WSAENOTCONN As Long = 10057
162162
Private Const ERR_TIMEOUT As Long = &H800705B4
163-
Private Const INVALID_SOCKET As Long = -1
164163

165164
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
166165
Private Declare Function IsBadReadPtr Lib "kernel32" (ByVal lp As Long, ByVal ucb As Long) As Long
@@ -552,7 +551,7 @@ Public Property Get IsClosed() As Boolean
552551
If m_bUseTls Then
553552
IsClosed = TlsIsClosed(m_uCtx) Or TlsIsShutdown(m_uCtx)
554553
Else
555-
IsClosed = (m_oSocket.SocketHandle = INVALID_SOCKET)
554+
IsClosed = m_oSocket.IsClosed
556555
End If
557556
End Property
558557

@@ -1097,6 +1096,11 @@ Public Function Create( _
10971096
Optional ByVal SocketType As UcsAsyncSocketTypeEnum = ucsSckStream, _
10981097
Optional ByVal EventMask As UcsAsyncSocketEventMaskEnum = ucsSfdAll, _
10991098
Optional SocketAddress As String) As Boolean
1099+
If m_bUseTls Then
1100+
If IsClosed And Not m_oSocket.IsClosed Then
1101+
m_oSocket.Close_
1102+
End If
1103+
End If
11001104
Create = m_oSocket.Create(SocketPort, SocketType, EventMask, SocketAddress)
11011105
End Function
11021106

0 commit comments

Comments
 (0)