Jump to content
  • Advertisement
Sign in to follow this  
Bow_vernon

slow accept??

This topic is 2928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I made a server program with non blocking socket, and it seems that the accepting process is slow...although it's not blocking, but it doesnt give error...can anyone explain this??oh and I select() then if there's pending connection, I accept()

Share this post


Link to post
Share on other sites
Advertisement
Describe what you mean by "slow". Can you post your code? Try to reduce it to the bare minimum that reproduces the issue you're having.

Share this post


Link to post
Share on other sites
well, I log every events in the app, and I run server and client at the same pc..and it seems that they're sharing CPU time, so maybe it's caused by CPU scheduling...but Id like a good explanation from others..google doesnt help.and I cant post the code now...

Share this post


Link to post
Share on other sites
Bow_vernon: Rip-off actually made a good suggestion. I second it.

* Can you reduce your problem to the smallest possible case?
* Create two programs that each are 20 lines long, and show the problem?
* Alternatively, if you log the time stamps, can you copy and paste the bits of the log that show that there's actually a problem, so we can see what you mean?
* Is slow one millisecond? ten milliseconds? one second? ten seconds?
* Also, seeing the lines surrounding your calls to send, recv, select and accept would be useful, but not hundreds of lines of code.

I recommend you go through this simple method of analysis before you post, so that it's at least minimally possible for people outside your room to understand what the problem really can be.

In general, a network program should not be CPU bound (it should be sleeping when there are no events), and a graphics program should not be CPU bound (it should be fill rate bound, at the limit). You can open the CPU meter of your OS, and check if any CPU is running pegged. If so, you're probably busy-polling in some loop. If you have more busy loops than CPU cores in your system, you will end up with pre-emptive scheduling, which will rotate through the different threads/processes at a time slice that varies by OS, but is generally on the order of hundreds of milliseconds.

Btw: I often end up thinking I don't know the solution to a problem. Then I'll post to some internet forum. Then, as part of writing the post, where I try to thoroughly explain the entire problem to the others in the forum, I find that I walk through the problem step by step, describing "well, it's not X, because I checked Y, ..." and, before I'm done posting to the forum, I've actually solved the problem myself. Just the process of formulating all the symptoms you are seeing, and then walking through "it could be X, because I don't think so because of Y" for each is a very helpful methodology.

Share this post


Link to post
Share on other sites
sorry, hplus, you made me feel guilty :p. but I think you're right, I call sleep(0) at the end of the server main loop, and the problem's gone. anyway, I guess it was slow because the client ate the CPU. I tested the server with telnet and it's accepting damn fast.I learnt a lot from ths stupidity..

Share this post


Link to post
Share on other sites
Feeling guilty is OK; calling yourself stupid is not :-)
Learning is crucial, and learning how to learn is the best kind of learning. I hope I never stop doing that myself, to be sure!
Glad you got it working.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!