|
-
Nov 26th, 2009, 04:13 PM
#1
Thread Starter
Hyperactive Member
Winsock freezing the app
Hi guys,
recently i made an app...that connects to a server with 30 connections at the same time with crypted data. and when the server gets that data it should send it back...to check if a serial is blacklisted or not.
the problem is when i tried to simulate 30 instant connections to the server...winsock pretty much liked to freeze the app..and the only way to end it is ctrl alt del
i tried to put DoEvents in the connect procedure like
If Winsock1(Index).State = sckConnected Then
.senddata
DOEVENTS
end if
do events made the app a bit more clickable and moveable..but the app still likes to freeze itself...
any idea? is it the winsock control? should i use api?
cheers
Thanks for helping me out.
-
Nov 27th, 2009, 10:01 AM
#2
Re: Winsock freezing the app
30 connections shuldn't be any problem at all using the Winsock control. I'd look elsewhere first.
Using DoEvents() calls in Winsock programming is often a sign you're doing something wrong though. If it helps at all to sprinkle them in there it sounds suspicious.
My guess would be that you are trying to blast data out over and over again (SendData calls) without waiting for SendComplete events. Without seeing some code though all we can do is guess wildly.
-
Nov 27th, 2009, 10:16 AM
#3
Thread Starter
Hyperactive Member
Re: Winsock freezing the app
wow cool answer 
i never did implement the sendcomplete thing :O
how do i use it?
ok will send out the code ...
Thanks for helping me out.
-
Nov 27th, 2009, 10:33 AM
#4
Re: Winsock freezing the app
SendComplete events occur as a prompt from the Winsock control telling you that there is space in the outgoing buffers for more data, and that calling SendData will not block at that point.
If you haven't written your program to work with SendComplete you may find you have some reworking to do.
-
Nov 27th, 2009, 10:39 AM
#5
Thread Starter
Hyperactive Member
Re: Winsock freezing the app
what i did is...
ON CLICK :
winsock.close
winsock.connect .....
WINSOCK CONNECT:
if state = connected then
send data
doevents
end if
WINSOCK DATAARRIVAL:
.GetData strReturn, vbString
WINSOCK CLOSE:
winsock.close
edit the recieved string.ecc
that's what i do
Thanks for helping me out.
-
Nov 27th, 2009, 10:51 AM
#6
Re: Winsock freezing the app
Do you just do one SendData each time you Connect?
Why would you check the State in the Connect event? Seems very redundant.
There must be something else going on. I don't see anything in your psuedocode that would seem to cause your program to seize up, and calling DoEvents at the end of an event handler shouldn't do anything useful in itself. There must be a lot more going on.
-
Nov 29th, 2009, 07:48 AM
#7
Thread Starter
Hyperactive Member
Re: Winsock freezing the app
well when i connect i then choose if state=connected then send the data.
and i get the data when the winsock closes the connection
Thanks for helping me out.
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
|