|
-
Aug 18th, 2004, 03:15 PM
#1
Thread Starter
PowerPoster
Winsock - Connection (array)
This amkes no sence to me but on the 2nd connection i get the "ivalid operation at current state" error which means the socket is in use,
VB Code:
Dim x As Long ' counter
If Winsock.UBound < 1 Then 'this is our first connection so accept it
Load Winsock(Winsock.UBound + 1)
Winsock(Winsock.UBound).Accept requestID
End If
For x = 1 To Winsock.UBound + 1 'loops through existing connections to amke sure we have none spare
If Winsock(x).State <> sckConnected Then
Winsock(x).Accept requestID '<<Error here!
Else
If x >= Winsock.UBound Then 'there si none spare so accept on new socket
Load Winsock(Winsock.UBound + 1)
Winsock(Winsock.UBound).Accept requestID
Exit Sub
End If
End If
Next x
i cant understand maybe its a simple error?
PINO
-
Aug 20th, 2004, 11:44 AM
#2
Thread Starter
PowerPoster
Any one at all? see any problems?
-
Aug 20th, 2004, 12:17 PM
#3
Errr...U can't accept the request twice.
U r accepting it a 2nd time in the For loop.
PLUS...It's for lngIndex = 1 to Winsock.Ubound
Not + 1.
Think this may solve your error problem.
You could always compile my winsock DLL. I wrote this DLL to take away the hassle of winsock control arrays, which suck 
The DLL also handles data that spans many "packets".
I can see what you're trying to do with the control array, but I don't like it, just me I think, as loads of developers do it your way.
Woof
-
Aug 20th, 2004, 12:22 PM
#4
Hmmm...OK, I was wrong. Juts looked at your code again. Ooops.
What line is the error on?
Woof
-
Aug 20th, 2004, 12:26 PM
#5
Thread Starter
PowerPoster
your wrong? well ir emoved the +1 to get this code...
VB Code:
Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim x As Long ' counter
If Winsock.UBound < 1 Then 'this is our first connection so accept it
Load Winsock(Winsock.UBound + 1)
Winsock(Winsock.UBound).Accept requestID
End If
For x = 1 To Winsock.UBound 'loops through existing connections to amke sure we have none spare
If Winsock(x).State <> sckConnected Then
Winsock(x).Close
Winsock(x).Accept requestID
Else
If x >= Winsock.UBound Then 'there si none spare so accept on new socket
Load Winsock(Winsock.UBound + 1)
Winsock(Winsock.UBound).Accept requestID
Exit Sub
End If
End If
Next x
End Sub
i through 4 connections at it and it seems fine? thank you? i think?
-
Jun 27th, 2008, 02:03 AM
#6
New Member
Re: Winsock - Connection (array)
hi,
I'm fairly new to Winsock, and i'm trying to make some simple chat software. I've been looking on google for various Winsock tutorials, but can't find any that are simple enough for a beginner, but also good enough to ensure that i actually learn what is trying to be taught...
If anybody knows a good tutorial, with examples, etc. Then please could you tell me the link.
Thanks & Regards,
Muthukumaramani.S
Note: This is for VB 6
-
Jun 27th, 2008, 04:28 AM
#7
Thread Starter
PowerPoster
Re: Winsock - Connection (array)
Very old thread you should really create a new one!
http://www.vbforums.com/showthread.php?t=297308
That should help thats as simple as you will get.
Good Luck
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
|