The Client (Java Applet)
will send byte arrays to the server, the first byte saying the information that is sent, the following bytes that information.
E.G. send a byte 1 asking "can move into area?" followed by the area coordinate.
Then waits for a reply from the server before taking action
E.G receives a byte 0 meaning "no its a wall"
the format I imagine something like:
onKeyPress(key)
{
if (!moving)
{
SocketManager.sendQuery(1, 25, 46);
Byte[] query;
double Start = System.getNanoseconds();
while ((query = SocketManager.queryReply()) == null)
{
if (System.getNanoseconds() >= Start + Timeout)
{
Error("Connection Timed Out");
return;
}
}
if (query[0] == 1)
{
Move(25, 46);
}
}
}
The Server (C++ server)
simply takes the queries sent by the client and answers them, occasionally checking for connection time outs and letting clients know if another player is near by (so they can draw it on screen and interact with it)
does anyone have any good sources / tutorials for this?
I've found a few which are poorly commented and simply say "this bunch of lines does this" when I would like to know what the functions and arguments do and what are the options etc.
Any and all help appreciated,
thanks in advanced,
Bombshell






