self.Control(i) Not returning sockets

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.

but if you loop through all the controls like

for i as integer = 0 to self.ControlCount-1
    dim c as Control = self.Control(i)


and you put an ipcsocket on the window that socket is not part of that list of controls

so i’m not sure how you mean to use introspection ?

I think this may help.

Var o As Runtime.ObjectIterator = Runtime.IterateObjects While o.MoveNext ListBox1.AddRow(Introspection.GetType(o.Current).Name) Wend

So if the type os TCPSocket… you can call close?

ah but he only wants the ones that are ON a specific window (he dragged them on there in the IDE)

the normal means of walking all the controls on a iwindw doesnt report these kinds :frowning:
it seems to only be RectControls

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.

I sent Josh some other code that makes this possible in a different way
Still walking the runtime object list is another alternative