CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2001
    Location
    India
    Posts
    49

    SOS : Accepting multiple connections using Winsock

    I am using Winsock control in my application with TCP protocol. It is supposed to accept more than one client request. The problem is i am able to accept only one ConnectRequest. What do i need to do inorder to accept more than one client requests. I am following the hints given in MSDN exactly, but i feel i am doing something terribly wrong somewhere.

    Thanks in advance,


    Vivek ([email protected] or [email protected])

  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: SOS : Accepting multiple connections using Winsock

    You will need to use a control array or winsock controls. What I always do is create one winsock (sckListen) which I use to listen for incoming connection, and a control array (sckAccept) to accept the actual connctions. You will need to add 1 sckAccept, and give it index 0. Code looks something like this:

    Code:
    private iCnn as Integer
      
    private Sub Form_Load()
        sckListen.LocalPort = 1024
        sckListen.Listen
        Msgbox "Socket listening"
    End Sub
      
    private Sub sckListen_ConnectionRequest(RequestID as Long)
        iCnn = iCnn + 1
        Load sckAccept(iCnn)
        sckAccept(iCnn).Accept RequestID
    End Sub
      
    private Sub sckAccept_DataArrival(Index as Integer, byval bytesTotal as Long)
      
        Msgbox "someone is sending something over connection " & Index
      
    End Sub


    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Last edited by Cimperiali; May 1st, 2003 at 02:21 PM.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured