How does one loop through all sockets on a window or find out of any exist, without knowing their name? I mean, I can loop through RunTime objects, but there’s no way to know if the one in the iterator is on a specific window.
Reason being… sockets can still fire events after the window they were on is closed/closing! I’m not sure if this is a leak, or by design.
To loop through objects try Introspection and checking their class type.
I put my TCPSocket sub class on my window (in the IDE) and turn it into a control set.
Works great.
Dim currentWindowName As String = Introspection.GetType(Self).Name
Dim o As Runtime.ObjectIterator = Runtime.IterateObjects
While o.MoveNext
If Introspection.TypeInfo(Introspection.GetType(o.Current)).BaseType <> Nil Then
If Introspection.TypeInfo(Introspection.GetType(o.Current)).BaseType.Name = "TCPSocket" Then
If Left(Introspection.TypeInfo(Introspection.GetType(o.Current)).FullName, len(currentWindowName )) = currentWindowName Then
'TCPSocket found on current window
Dim t As TCPSocket = TCPSocket(o.Current) 'We can now do what we want with the TCPSocket
End If
End If
End If
Wend
Honestly though, you should close down your TCPSockets in your Window.Close so they don’t cause you the issues you mentioned.