Whenever I close a socket and remove it from an array from the SSLSocket Error event, the object count does not decrease.
This issue does not happen if I change it to a normal TCPSocket.
This issue also doesn’t happen if a use a timer in the error event: “Timer1.Period = 0”
Given that this issue doesn’t happen with a TCPSocket, and that it doesn’t happen with a timer, it would seem to be a bug.
But I could certainly be doing something wrong.
Tested with the latest version: 2014r2.1
Project:
http://www.filedropper.com/sslsocketleak
http://speedy.sh/fHx5N/SSL-Socket-Leak.rbp
Code:
Sub Action()
TextArea1.Text = ""
Dim s As new sckSSL
s.Address = TextField4.Text
s.Port = Val(TextField5.Text)
if CheckBox1.Value = True Then
s.Secure = True
Else
s.Secure = False
End If
sckSSL.inc = sckSSL.inc + 1
s.id = sckSSL.inc
sckSSL.sslArray.Append s
s.Connect
me.Enabled = False
End Sub
Sub Error()
Window1.Objects
Window1.Listbox1.AddRow "Disconnected: " + CStr(me.id)
If Window1.CheckBox2.Value = True Then // Use workaround
timerID = me.id
Window1.Timer1.Period = 0
Window1.Timer1.Mode = timer.ModeSingle
Window1.Timer1.Enabled = True
Else // No workaround
sckSSL.SockKill me.id
End If
End Sub
Shared Sub SockKill(sockID As Integer)
for i As Integer = UBound(sslArray) DownTo 0
if sckSSL.sslArray(i) <> nil Then
if sckSSL.sslArray(i).id = sockID Then
sckSSL.sslArray(i).Close
sckSSL.sslArray(i) = nil
sckSSL.sslArray.Remove i
Window1.Listbox1.AddRow "Killed: " + CStr(sockID)
Window1.Objects
Window1.PushButton1.Enabled = True
Return
End If
End If
next i
End Sub