I mean like this:

This code is from the server I made for work, wich we use for more than a year now...
VB Code:
  1. Private Sub SckTCP_Close(Index As Integer)
  2.     CClients = CClients - 1
  3.     SckTCP(Index).Close
  4.     ClearUser Index
  5.    
  6.     If Index = 0 Then
  7.         ConnectAllSockets
  8.     End If
  9. End Sub
  10.  
  11. Private Sub SckTCP_ConnectionRequest(Index As Integer, ByVal requestID As Long)
  12.     Dim K As Integer, SHA As New clsSHA256, StrToSend As String
  13.    
  14.     For K = 1 To SckTCP.UBound
  15.         If SckTCP(K).State = sckClosed Then Exit For
  16.     Next K
  17.    
  18.     If K = SckTCP.UBound + 1 Then
  19.         Load SckTCP(SckTCP.UBound + 1)
  20.         Load tmrSendData(SckTCP.UBound)
  21.        
  22.         ReDim Preserve Clients(SckTCP.UBound)
  23.        
  24.         K = SckTCP.UBound
  25.     End If
  26.    
  27.     Randomize
  28.     Clients(K).State = 0
  29.     Clients(K).CLogIn.RndINIT = UCase(SHA.SHA256(CStr((2 ^ 30) * Rnd)))
  30.    
  31.     SckTCP(K).Accept requestID
  32.    
  33.     StrToSend = "RndINIT|" & Clients(K).CLogIn.RndINIT
  34.     SckTCP(K).SendData Len(StrToSend) & ":" & StrToSend
  35.    
  36.     CClients = CClients + 1
  37. End Sub