Using Sleeps() in my Winsock application 
Author Message
 Using Sleeps() in my Winsock application

I created a TCP/IP Server that takes requests from clients. The clients
right now only pass hard coded files, ie, I am passing mp3 or exe over the
wire to get from point a to point b. It seems like the server gets over
loaded and craps out but if I put Sleep(100) in my sending (client) loop,
the server works fine. I am assuming doing this is just bad development and
I am not accounting for something on the server end. True? False? Anyone?

Thanks
Ralph Krausse



Tue, 25 May 2004 23:27:40 GMT  
 Using Sleeps() in my Winsock application
Hi Ralph,

I had similar problems too. Most probably your server listening port will be
on a thread and on continuous loop [for or while] looking for incoming data
from the client. Very well.

Now take a simiple thread no socket nothing, but doing some arthimatic
addition or subtraction in an indefinite while or for loop. Open up your
windows Task manager and look for process time consumed by your application,
to our surprise it will be more than 90%. Try putting Sleep(10) in the for
or while loop, you will see a remarkable difference in the process time and
the process time should drop to less than 5% now. What you think?.

Actually these sleep statement allow the windows thread scheduler to server
other parallel running threads in the system, please remember Windows is an
Pre-emptive operating system with one processor, you can't run two
simulatenous threads. So, with sleep statement, thread scheduler is
scheduling other threads to the processor. Without a sleep statement thread
quantum time for your running threads will be too much and the processor
time too much.

I have my socket server application running with a sleep(50) in a while loop
and I had no problems so far in connecting to clients with or without sleep.

Take care,
Jegan.


Quote:
> I created a TCP/IP Server that takes requests from clients. The clients
> right now only pass hard coded files, ie, I am passing mp3 or exe over the
> wire to get from point a to point b. It seems like the server gets over
> loaded and craps out but if I put Sleep(100) in my sending (client) loop,
> the server works fine. I am assuming doing this is just bad development
and
> I am not accounting for something on the server end. True? False? Anyone?

> Thanks
> Ralph Krausse



Wed, 26 May 2004 00:06:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Winsock Winsock Winsock !!!

2. interrupt sleep() or successive sleeps

3. Application being put to sleep, why?

4. Winsock program in SDI application

5. Doubts about winsock program in SDI application

6. Winsock program in SDI application

7. Help in creating a WSAEventSelect model winsock client application

8. a Question when Create Service application with Winsock supported

9. a Question when Create Service application with Winsock supported

10. Doubts about winsock program in SDI application

11. Q: How to set Sleep() between Sleep(0) and Sleep(1)?

12. Winsock OXC vs.Winsock DLL

 

 
Powered by phpBB® Forum Software