Results 1 to 3 of 3

Thread: multiple connections creating controls

  1. #1

    Thread Starter
    Lively Member meander's Avatar
    Join Date
    Jun 2004
    Posts
    121

    multiple connections creating controls

    i know this has been discussed a lot here, but for some reason i dont seem to understand. I have managed to make a simple chat program using one winsock control, and such. now i would like to expand this. I read that you can create new controls when needed, so i would assume once a connection is made, it would spawn another control so as to accept another connection, and i read that it is easiest with an array. i also realise that with multiple connections, it would probably be easiest to have one dedicated server software that all the clients connect to, and then delegate the connections or messages from there.
    I'm having a problem here. Do I put the serial number in the box that says 'serial number,' or do I put it in the box that says 'company'? - Oh, those poor tech support people

    Jiveman: Lookie here, I can dig grease and butter on some draggin' fruit garden.

  2. #2
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: multiple connections creating controls

    Here's what you do. You create one server, and one client. I'll explain the server first. On your server, add 2 winsock controls, and make one of them have an index of 0 since it will be a control array. One of these controls will listen and handle all incoming connections. When an incoming connection request is recieved, a new socket is loaded for the control array, which accepts the incoming connection and establishes a connection with the user connecting. It looks something like:

    VB Code:
    1. Public lmaxsocket As Long
    2. Private Sub scklisten_ConnectionRequest(ByVal requestID As Long)
    3.     Dim lsockcount As Long
    4.  
    5.     lsockcount = NewSocket()
    6.     sckconnection(lsockcount).Accept requestID
    7. End Sub
    8. Private Function NewSocket() As Long
    9.     lmaxsocket = lmaxsocket + 1
    10.     Load sckconnection(lmaxsocket)
    11.     NewSocket = lmaxsocket
    12. End Function

    As you can see, upon recieving a request, a new socket is created from the control array, and then that new socket accepts the incoming connection. When you send out data, if you want to send it to all connected users, simply do something like:

    VB Code:
    1. For x = 0 To lmaxsocket
    2.     sckconnection(x).SendData "MyCommand"
    3. Next x

    The client just simply connects to the server, and does as needed. Did I goto fast?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  3. #3
    Hyperactive Member Vishalgiri's Avatar
    Join Date
    Oct 2003
    Location
    India
    Posts
    345

    Re: multiple connections creating controls

    All the Connections will be One to One, So I was wondering If some one can help me for Many to One connection.
    Regards,
    Vishalgiri Goswami
    Gujarat, ( INDIA ).
    ---------------------

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