Jump to content
  • Advertisement
Sign in to follow this  
darkchrono4

Keyboard Input and Multiple Clients

This topic is 4636 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

Playing around with a multi client chat program to get familiar with Winsock. Trying to think of how to wait for keyboard input while still having Winsock send and receive messages. Only thing I can think is putting the send/recv calls into a seperate thread and just actually send data when there is info in the text buffer. Is this how its usually done? Or is there some other way? I am trying to stay away from boost and other librarys of that nature.

Share this post


Link to post
Share on other sites
Advertisement
I guess I should have specified I'm having a problem more with the keyboard input. Right now I'm just using gets() which just sits and waits until enter has been pressed. I know there has got to be a better way then that.

Share this post


Link to post
Share on other sites
On unixy systems, you can simply add "0" to the select() call. 0 is STDIN, and if there's data on it, will be listed in the fd_set for you to then call read() [or whatever] on like you do with sockets.

On Windows, ReadConsole() is non-blocking [iirc].

Share this post


Link to post
Share on other sites
http://www.gamedev.net/community/forums/topic.asp?topic_id=285863&whichpage=1�

Seems to be a good discussion on it. I was searching realizing how little I remember :(

You can also use GetAsyncKeyState if you can't find another way to do it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
#include
...
if (kbhit()){
// a key on the keyboard has been hit.
}
...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
kbhit is inside the conio.h header

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!