I am going to make a program that use multiple winsock, and using a class module to create that winsock support socks proxy. Now i confused how to make array of that class in form to load multiple winsock. Thanks...........
Printable View
I am going to make a program that use multiple winsock, and using a class module to create that winsock support socks proxy. Now i confused how to make array of that class in form to load multiple winsock. Thanks...........
You can use a collection.
I mean we load multiple winsock like this example:
set index to 0 of winsock property Window
then in command we just write "load winsock" and connect or close or sendata Like this "Winsock(index).senddata......"
So can I do the same in class module like set Myclass(index) = new Myclass or what
I need help on this...........
Please post a COMPLETE example of what you are doing otherwise it is unclear as to what to suggest.
This is the class module i have using, How to use this socket.cls multiple like Loading Multiple winsock.
suppose if i use winsock array(indexed winsock) to connect a site then method is
How to do the same with This class, how to declare that class as arrayCode:winsock(index).connect remote host, remote port
this code will make a single socket
Code:Private WithEvents Socket1 As Socket
but i need this socket load multiple number, say 10 socketsCode:form load
Set Socket1 = New Socket
Use a collection. That's what they are for. You can not make an array of classes in VB6 or earlier. If you really insist on an array of classes then you need to switch to .NET.
It is a very common mistake to wrap a Winsock control in a Class.
Rewrite this Class as a UserControl, which is what it should have been in the first place. Your problems will disappear.
A collection is very easy to use.
To useCode:Dim mcolSockets as Collection
Sub Form_Load()
Set mcolSockets = New Collection
mcolSockets.Add(Socket1)
End Sub
I don't have VB6 here so I had to write that without an IDE, it may not be perfect. Try using it then post your code if you have problems and we can help. dilettante is a VB6 coder so he can help as well.Code:mcolSockets(index).connect remote host, remote port
Using a Collection won't help much because you won't get control array event semantics.
A rewrite as a UserControl should be almost trivial. Most of the code can be copied right in without change. You could clean up some of that messy code at the same time.
thank u, lets try. if solved I will inform u both