PDA

Click to See Complete Forum and Search --> : Connection Help


winapi
Jul 2nd, 2000, 02:26 PM
Hi,
Can someone please look at this code and tell me why it is not working. I am trying to accecpt multi connections via winsock.I have one winsock control named wsock1 which listens on port 5000 for connections and wsock2 for data send/recv. Everytime the second person trys to login into the server, it fails and never runs the connection_request event. The client sits at wsock1.state=6

Here is my code

Private Sub wsock1_ConnectionRequest(ByVal requestID As Long)
dim newport as integer
newport = -1
For x = 0 To wsock2.Count - 1
If wsock2(x).State = 0 Then newport = x: Exit For
Next

If newport = -1 Then Load wsock2(wsock2.Count):newport=wsock2.Count - 1

wsock2(newport).Accept requestID
wsock1.Close
wsock1.Listen