Sign in to follow this  
Sir Sapo

Client Extrapolation

Recommended Posts

Sir Sapo    769
Alright , I have 2 questions for you guys. 1. When I call a recv() in winsock using TCP protcol, will the program wait there until it recieves something, or does it just keep going if it doesn't recieve anything. 2. I'm trying to have my networked games server send data only about 5 times a second, and have the client extrapolate where everyone will be until it recieves new data. Right now, the game runs at 5 FPS, I think because it sits there and waits for the data. In order to fix this, should I send a little bit of info everytime the server updates, that says whether to wait for data, or update autonomously from the server? Here's some psuedo-code for what I'm trying to explain:
//Server Code

if(updatetime)
{
send(timetoupdate);
send(allthedata);
}

if(!updatetime)
{
send(nottimetoupdate);
}


//Client Code

recv(doIupdate);

if(doIupdate)
{
recv(allthedata);
}

if(!doIupdate)
{
Extrapolatestuff();
}


Can anyone clarify this for me?

Share this post


Link to post
Share on other sites
SiCrane    11839
Function calls for socket I/O can be either blocking or non-blocking. It sounds like you're current source codes uses blocking sockets. In Winsock, to make the calls non-blocking you can use ioctlsocket() with the FIONBIO command to make a socket non-blocking. Also calls to WSAAsyncSelect() or WSAEventSelect() should also make a socket non-blocking.

Share this post


Link to post
Share on other sites
hplus0603    11347
Typically, you'll check for readable sockets using select(). When a TCP socket is returned as readable, it will return whatever data is available (without blocking) the first time you call recv() after that. An alternative is to make the socket non-blocking. The Forum FAQ has pointers to more information.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this