|
-
Mar 24th, 2008, 06:39 PM
#18
Re: Winsock Multiple Connections
 Originally Posted by emyztik
So, which should fix the problem? Now I'm confused 
Use this:
 Originally Posted by DigiRev
Well, according to that code, k will never be > than .UBound
Try this
Code:
Private Function NextSocket() As Integer
Dim i As Integer, intRet As Integer
If wsServer.UBound = 0 Then
Load wsServer(1)
NextSocket = 1
Else
For i = 1 To wsServer.UBound
If wsServer(i).State = sckClosed Then
intRet = i
Exit For
End If
Next i
If intRet > 0 Then
NextSocket = intRet
Else
intRet = wsServer.UBound + 1
Load wsServer(intRet)
NextSocket = intRet
End If
End If
End Function
Private Sub wsServer_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim i As Integer
i = NextSocket
If i > 0 Then
wsServer(i).Accept requestID
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|