• Advertisement
Sign in to follow this  

sleep

This topic is 2995 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`m trying to use raknet and I`m wandering what does the sleep function do, there`s sleep and RakSleep, they probably do the same thing but I`m trying to figure out what exaclty they do. The code to capture network input in the RakN samples is wrapped in a while(true) which I guess puts the system/windows in a comma. Also
while (1)
	{

	// This sleep keeps RakNet responsive
	RakSleep(30);

#ifdef _WIN32
		if (kbhit())
		{
			// Notice what is not here: something to keep our network running.  It's
			// fine to block on gets or anything we want
			// Because the network engine was painstakingly written using threads.
			gets(message);
what does the function kbhit() stand for. Does it check if something (packet) has arrived? [Edited by - Calin on December 7, 2009 9:18:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
Raknet runs its own thread. RakSleep(30); tells the raknet thread to take a break.
Sleep() tells your thread to take a break.
kbhit() is Key-Board-Hit, checks if a button has been pressed on your keyboard.

Share this post


Link to post
Share on other sites
The RakNet function is for RakNet's implementation. For example, it might allow incoming data to still be dequeued but not dispatched (just guessing here -- check the documentation to be sure).

sleep() comes from the standard C library, and does what it says -- suspend the current thread for some number of seconds.

kbhit() is a Microsoft specific C function which checks if a keyboard key has been hit. It's documented on MSDN.

Share this post


Link to post
Share on other sites
thanks

why does the server waits for keyboard input though. Should't it check and display the incoming packets/text in realtime? That's what it does. When I type in the client console the text shows up in the server console right away without any input from the user.

[Edited by - Calin on December 8, 2009 3:18:16 PM]

Share this post


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

  • Advertisement