Results 1 to 6 of 6

Thread: Creating multiple winsock connections (anyone got books online??)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    36
    I need to know how to make multiple client connections to one server with winsock.

    I did have a print out from the visual basic books on line thing but I've lost it.

    If anyone has the book thingy please copy/paste that section into this forum. Or anyone godly enought to know how to solve my prog PLEASE HELP!

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Its not that hard, you load a new winsock when receiving a new connection request and connect at port 0.

    If you need code you can download a chat demo from my website.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    36

    Are yes,

    I though it'd come down to loading objects, somthing I've never done before.

    I've only been writeing VB for about 8 months and the 3 or 4 programs I've done have been complex but basicaly Qbasic code in a button with a few text box's.

    Help on loading Objects would be nice (and why port 0?)

  4. #4
    Guest
    I think you can do it like this

    Code:
    Dim MeMe As Winsock

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You set the index property of the winsock to 0 and load them by index:
    Code:
    Count as Long
    
    onConnectionRequest()
       Count = Count + 1
       Load Winsock(Count)
       Winsock(Count).AcceptID
    End Sub
    Port 0 automatically connects with a free port so you can use your port for more connections. Else after the first connection the port would be blocked... (or something, Im not that sure but I think its that)

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb Create a new instant is the faster solution. (I think So)

    Properly you can have 2 form:

    frmMain.frm >> Consits of a WinSock Control.
    frmWSck.frm >> Also Consits of a Winsock Control.

    Set thr frmMain.frm as you startup form. So when ever the Winsock control in the frmMain.frm received as Connection Request then it create a new instant for the frmWSck.frm and therefore, you'll have a multiple Winsock connection.

    Code:
    'Under the frmMain.frm Winsock control
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
      Dim nWsck As New frmWSck
      Load nWsck
    End Sub

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