Client Extrapolation

Started by
1 comment, last by hplus0603 18 years, 9 months ago
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?
My Current Project Angels 22 (4E5)
Advertisement
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.
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.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement