We help IT Professionals succeed at work.

Collection which responds to events...

Hi all,

I'm trying to create a Telnet server class.  I just added
a reference to the winsock object and a listener object.
Now ... to handle all connection requests i need to
have some sort of collection from where the events of the
sockets fire independently.  How is this done precisely?
Sample code would be appreciated.

Thanks in advance...
Watch Question

TimCotteeHead of Software Services

What you do is create the winsock object with an index of 0 (zero) when you get a connection request, simply load another element in this control array:

Load Winsock(1)

And accept the connection on this new object. The events for the control will then get an Index property passed to them which identifies the socket that is receiving the event.


The problem is that i'm trying to do this in a class (no form)...

So if you try this in the class module...

Option Explicit

Private WithEvents sckListener As MSWinsockLib.Winsock
Private WithEvents sckSockets (0) as MSWinsockLib.Winsock

It just doesn't work ;)
have a look at:
it refers to events from a collection of user controls, but the principals (ie using an intermediate parent-callback class) are the same.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.