Results 1 to 2 of 2

Thread: winsock help please (SOLVED WITH THANKS)

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    129

    winsock help please (SOLVED WITH THANKS)

    Hi all, im trying to get this wonsock fuction to work.

    I have another program which connects to this program via winsock.

    I have placed a Winsock Object on the form called sckMain and gave it a index of Zero to make it a control array.

    Im trying to impliment this from web sites that i have been reading. This part of the program check though a array called bolArray ( a boolean array) which im runnig along side the sckMain array. It check to see if the value ios true (user logged onto that sckMain array) and if not loops around untill it finds a array that is free or false.

    Then it assignes that user that sckMain array number. This is get multiple users being able to log into the main server porgam.

    Im new to Winsocsk and im not sure my logic is sound. This isnt working im getting a OBJECT requierd at Load Winsock(Winsock.i) I tried changeing the Winsock to the name of my winsock array sckMain but that didnt work. Can anyone shine some light ont his for me please?


    VB Code:
    1. Private Sub sckMain_ConnectionRequest(Index As Integer, ByVal RequestID As Long)
    2.    
    3.     For i = 1 To UBound(bolArray)
    4.         If bolArray(i) = False Then
    5.        
    6.             ' load a new winsock
    7.             Load Winsock(Winsock.i)
    8.             ' accept the incoming connection on our new control
    9.             Winsock(Winsock.i).Accept RequestID
    10.             bolArray(i) = True
    11.             txtMessageDisp.Text = txtMessageDisp.Text & vbNewLine & "SYSTEM: Accepted a New Connection on Winsock " & i
    12.             Exit Sub
    13.         End If
    14.     Next i
    15.     ' load a new winsock
    16.     Load Winsock(Winsock.UBound + 1)
    17.     ' accept the incoming connection on our new control
    18.     Winsock(Winsock.UBound + 1).Accept RequestID
    19.     txtMessageDisp.Text = txtMessageDisp.Text & vbNewLine & "SYSTEM: Accepted a New Connection on Winsock " & (Winsock.UBound)
    20.    
    21.  
    22.  
    23.  
    24.     'sckWinsock1.Close 'this resets the socket ready to accept the incoming connection
    25.     'sckWinsock1.Accept requestID 'accept the connection!
    26.  
    27. End Sub
    Last edited by fgp123; Sep 20th, 2005 at 04:58 AM.

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