Results 1 to 7 of 7

Thread: Collection of Winsock Controls

  1. #1

    Thread Starter
    Lively Member Tw1sted L0gic's Avatar
    Join Date
    Jan 2005
    Posts
    88

    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

  2. #2
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Collection of Winsock Controls

    Show me what you've tried so I can show you where to go.

  3. #3

    Thread Starter
    Lively Member Tw1sted L0gic's Avatar
    Join Date
    Jan 2005
    Posts
    88

    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

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    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

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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:
    1. Private WithEvents Winsock As MSWinsockLib.Winsock
    2.  
    3. Set Winsock = New MSWinsockLib.Winsock

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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:
    1. Load Winsock1(Winsock1.Ubound + 1)
    2. Winsock1(Winsock1.Ubound). ... 'use whatever methods/properties you need

  7. #7

    Thread Starter
    Lively Member Tw1sted L0gic's Avatar
    Join Date
    Jan 2005
    Posts
    88

    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
  •  



Click Here to Expand Forum to Full Width