Client Side Performance

Started by
1 comment, last by hplus0603 15 years, 11 months ago
Ok so thanks to every one here I was able to redesign my console network apps server side to be very light on the cpu cycles. Basicly i went from while(1) { select(socket1,0seconds) select(socket2,0seconds) select(socket3,0seconds) } to while(1) { select(allsockets,hold till select sees something) } Now im trying to see how to do this on my client side? but i do a while(!_kbhit()) { select(connectedsocket,0seconds) } So i dont see how i can have a select thats not going to expire. Will I always have to have the continuse poll issue on the client side? Any help is always apperciated.
Do or do not there is no try -yoda
Advertisement
_kbhit is just completely the wrong way to check for input, since it stops and waits for a keypress. What you need is something that will tell you when a key has been pressed, without stopping to wait for such an event. Depending on your platform and your needs, it will either provide events for your keypresses (eg. WM_KEYDOWN on Windows), or provide API calls to check the current state of the keys (eg. GetAsyncKeyState on Windows).
If you want to wait both for keyboard messages and socket data, then you should use MsgWaitForMultipleObjectsEx() instead of select().
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement