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?
Printable View
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?
I would probably use an array of winsocks.
Why would you need to have more than one connection to the same server? Can you tell us what you are trying to do?
How can I use an array with the winsock?
ccoder:
I just want to play around with my code, no big reason.
That will just load so many winsock as you say so in TxtSocks :)vb Code:
Dim i as integer i = 1 Do Until i = Val#(TxtSocks.Text) Load Winsock(i) i = i + 1 Loop
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 :)
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?
Yea you could also do it the way that worked for you :) But that would mean more controls. Anyway well done and good luck :D
Yeah, Thanks :) But it still just sends the last data and skips the others :/
This sounds like a well known bug that was fixed in VB6 SP6. What service pack are you at?
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.
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
Thanks, hope it works for me too :)
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.
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?
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
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.
It probably would depend on the ports as well.