|
-
Jul 26th, 2005, 10:26 AM
#1
Thread Starter
Lively Member
Collection of Winsock Controls
Hi,
I'm having trouble creating a collection of Sockets, using the Winsock active-x control.
Can someone show me how to create a new instance of a socket, add it to the collection, and use the sockets events
thanks!
Naughty but Nice 
-
Jul 26th, 2005, 11:26 AM
#2
Re: Collection of Winsock Controls
Show me what you've tried so I can show you where to go.
-
Jul 26th, 2005, 11:34 AM
#3
Thread Starter
Lively Member
Re: Collection of Winsock Controls
Well I'd like to create instances, as I do with Class modules:
private withevents sckSocket as winsock
Set sckSocket = new winsock
But it won't let me. If anyone can give an example of how to maintain a collection of Winsock sockets, please let me know!
In fact I think I'll just use the clsWinsock class module and avoid the Active-x control. But I'm still interested how it can be acheived with the control.
Thanks
Naughty but Nice 
-
Jul 26th, 2005, 11:40 AM
#4
Re: Collection of Winsock Controls
You may wanna look into DirectPlay as an alternative to Winsock. Seems to work a lot better, plus it's used on Massive Multiplayer Online games. That'll give you an idea on what I mean on working a lot better 
http://externalweb.exhedra.com/Direc...TUT_DX8_DP.asp
-
Jul 26th, 2005, 11:43 AM
#5
Re: Collection of Winsock Controls
You'll have to add a refernce to MSWINSCK.OCX
Goto Project\References Browse to system32\MSWINSOCK.OCX
Then
VB Code:
Private WithEvents Winsock As MSWinsockLib.Winsock
Set Winsock = New MSWinsockLib.Winsock
-
Jul 26th, 2005, 11:49 AM
#6
Re: Collection of Winsock Controls
Since winsock is a control it must be added to Controls collection:
Set sckSocket = Form1.Controls.Add("ProgID", "new_name")
However, since Wisock IS NOT and Intrinsic control you must add a license to licenses collection ... so it's a pain ...
Instead of all those troubles use Control Array: create one instance of Winsock control in design, set Index = 0 so you can Load more instances at run time:
VB Code:
Load Winsock1(Winsock1.Ubound + 1)
Winsock1(Winsock1.Ubound). ... 'use whatever methods/properties you need
-
Jul 26th, 2005, 11:56 AM
#7
Thread Starter
Lively Member
Re: Collection of Winsock Controls
Yea, thanks very much. I've done it with arrays before, but you have to scan them when re-using sockets and loading them etc. I just thought it would be easier to have a collection.
Thank you all.
Naughty but Nice 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|