Link to home
Start Free TrialLog in
Avatar of Bcoloutlaw
Bcoloutlaw

asked on

VB 6 Client/server program with multiple clients connected to one server.

I Have created a program for a user that uses "WINSOCK" to connect the client program to the server. The problem is that the user demands to have several clients to connect to one server. How do I make this several or multiple clients to one server? Do I have to Use multiple winsock? if I do, then I would have to open multiple ports and it would slow down the server. What should I use to connect multiple clients to this one server? thankz!
Avatar of viper123
viper123

Do a loop checking for the socket.
private sub winsock1_connectionrequest

If Index = 0 Then

'// your code here
'// first connection to client

else

'// multiple client
 
varEnviron.SockMax = varEnviron.SockMax + 1

ReDim Preserve arrSockAvi(varEnviron.SockMax)

Load wskSocket(varEnviron.SockMax)

wskSocket(varEnviron.SockMax).LocalPort = _ varEnviron.LocalPort

wskSocket(varEnviron.SockMax).Accept requestID

end if
end sub

First set your winsock control's index value to 0 then
check this example.

Private intMax As Long

Private Sub Form_Load()
   intMax = 0
   sckServer(0).LocalPort = 1001
   sckServer(0).Listen
End Sub

Private Sub sckServer_ConnectionRequest _
(Index As Integer, ByVal requestID As Long)
   If Index = 0 Then
      intMax = intMax + 1
      Load sckServer(intMax)
      sckServer(intMax).LocalPort = 0
      sckServer(intMax).Accept requestID
      Load txtData(intMax)
   End If
End Sub



Bcoloutlaw:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
Bcoloutlaw, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of YensidMod
YensidMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial