|
-
May 3rd, 2007, 03:22 AM
#1
Thread Starter
Member
[RESOLVED] More connections with one winsock
Can I only connect as one client with a winsock?
winsock.Connect -
will get me connected to the server, but if I want to connect to the server twice at the same time with the same sock, how can I do that?
Or do I have to create another sock?
-
May 3rd, 2007, 07:57 AM
#2
Re: More connections with one winsock
I would probably use an array of winsocks.
-
May 3rd, 2007, 08:16 AM
#3
Frenzied Member
Re: More connections with one winsock
Why would you need to have more than one connection to the same server? Can you tell us what you are trying to do?
-
May 3rd, 2007, 08:22 AM
#4
Thread Starter
Member
Re: More connections with one winsock
How can I use an array with the winsock?
ccoder:
I just want to play around with my code, no big reason.
-
May 3rd, 2007, 08:29 AM
#5
Re: More connections with one winsock
vb Code:
Dim i as integer
i = 1
Do Until i = Val#(TxtSocks.Text)
Load Winsock(i)
i = i + 1
Loop
That will just load so many winsock as you say so in TxtSocks
-
May 3rd, 2007, 09:57 AM
#6
Thread Starter
Member
Re: More connections with one winsock
Doesn't I have to make the winsock as an array first?
Or can I do it like this:
winsock(0).RemoteHost = txtIp
winsock(0).RemotePort = txtPort
winsock(0).Connect
(And for the dataArrival)
winsock(0).SendData "x"
and so on.. with the next array variable? Like:
winsock(1).RemoteHost = txtIp
winsock(1).RemotePort = txtPort
winsock(1).Connect
(And for the dataArrival)
winsock(1).SendData "y"
edit:
btw, thanks for all the help
Last edited by Kurdistan; May 3rd, 2007 at 12:38 PM.
-
May 3rd, 2007, 01:21 PM
#7
Thread Starter
Member
Re: More connections with one winsock
Solved my problem 
Made a control array with the winsock on the form, and now just doing as my code above, with Load Winsock(5) and so on
EDIT:
Problem :/ It only sends the last one With:
winsock(0).SendData
winsock(1).SendData
it skips the first, and only sends the second. Any ideas?
Last edited by Kurdistan; May 3rd, 2007 at 02:04 PM.
-
May 3rd, 2007, 11:29 PM
#8
Re: More connections with one winsock
Yea you could also do it the way that worked for you But that would mean more controls. Anyway well done and good luck
-
May 4th, 2007, 12:20 PM
#9
Thread Starter
Member
Re: More connections with one winsock
Yeah, Thanks But it still just sends the last data and skips the others :/
-
May 4th, 2007, 03:10 PM
#10
Re: More connections with one winsock
This sounds like a well known bug that was fixed in VB6 SP6. What service pack are you at?
-
May 4th, 2007, 11:07 PM
#11
Thread Starter
Member
Re: More connections with one winsock
Not sure, Have'nt upgraded my VB6, so its probably at SP0.
But it works if I use a timer with 1 second between the sends.
-
May 5th, 2007, 01:24 AM
#12
New Member
Re: More connections with one winsock
Previously I was also having the same problem.
I also implemented it using the timer to give a gap between the send data command for more than one connection.
Now i have downloaded the vb6 updates from microsoft site. from following url
http://www.microsoft.com/downloads/d...displaylang=en
Now i don't need to keep a time gap in sending data.
Thanks
-
May 5th, 2007, 12:53 PM
#13
Thread Starter
Member
Re: More connections with one winsock
Thanks, hope it works for me too
-
May 5th, 2007, 06:22 PM
#14
Re: [RESOLVED] More connections with one winsock
For future reference by others, later service packs fix a number of Winsock control issues. Some of the nastier ones are:
FIX: Winsock Control SendData Only Works Over the Latest Connection
Winsock control may fire the DataArrival event after the Close event
Always be sure to install the very latest service pack you can get, which is pretty much SP6 unless Microsoft issues a new one someday. You only need to install the latest one, since each SP is cumulative.
-
May 5th, 2007, 06:49 PM
#15
Thread Starter
Member
Re: [RESOLVED] More connections with one winsock
Do you think it's a bug that I get the errormessage:
"Run-time error '40006':
Wrong protocol or connection state for the requested transaction or request"
when I connect with more than 400 connections to a server?
Want to try out how many users my application can handle.
Or is there anyother control rather than winsock?
-
May 5th, 2007, 09:08 PM
#16
Re: [RESOLVED] More connections with one winsock
That often occurs when the user uses the SendData or GetData methods before the winsock has connected.
Also have a look here....
http://download.microsoft.com/downlo...vbrun60sp5.exe
-
May 6th, 2007, 01:11 AM
#17
Thread Starter
Member
Re: [RESOLVED] More connections with one winsock
Strange, because it connects up to 350 socks, and then I get the error.
Or sometimes even less socks.
Thanks, I'll try that one too.
-
May 6th, 2007, 01:17 AM
#18
Junior Member
Re: [RESOLVED] More connections with one winsock
It probably would depend on the ports as well.
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
|