PDA

Click to See Complete Forum and Search --> : Winsock sleep


invitro
Apr 21st, 2000, 04:08 AM
Is there an api function to make a winsock control sleep for a certain amount of time without using a timer?

In my program i have a winsock with an index to be able to load a couple of them at a time, and if a connection is detected lets say on winsock(5) then the winsock will send over the data it is sappose to and sleep for a couple seconds.

Can anybody help me in making the winsock fall asleep with API or some other control?? Anything but a timer!

rekcus
Apr 21st, 2000, 05:35 PM
Try the GetTickCount API. But what's so wrong with the timer control?

Rgrds,

invitro
Apr 22nd, 2000, 12:47 PM
Timers are to hard to control, for me anyway aspecially if i have winsock(0-100) loaded, id have to make (0-100) timers for every winsock, and that would just take up to much resources, and slow things down and all that ****.
But thanks for the GetTickCount API, im not exactly sure how to use it yet but im sure ill figure out how it works. For now it gives me a value of 931123... i dont know how to read that but whatever, ill figure it out. Thanks for the reply, appriciate it!

privoli
Apr 22nd, 2000, 03:34 PM
Use a combination of Sleep and DoEvents, that will be more fuctional in your situation... see example code below...

Look up 'Sleep' in your API guide and use its declation.
Sleep only requires 1 parameter, that being duraiton in miliseconds.

Sleep 1000

1 second pause via API and system

'Example loop, causes problems with loading stress
'etc.. as you explained in your previous post...
For X = 1 to 100
Load SckSocket(x).UBound +1
SckSocket(x).LocalPort = X
SckSocket(x).Connect HostName(x)
Next X

'More effcient and productive loop
For X = 1 to 100
Load SckSocket(x).UBound +1
SckSocket(x).LocalPort = X
SckSocket(x).Connect HostName(x)

'Cause a pause and let system dump buffers etc...

DoEvents
Sleep 400
DoEvents

Next X

Any problems just reply to this post.