Game Development Community

Simple TNL example

by Cat · in Torque Game Engine · 11/05/2004 (8:31 am) · 9 replies

I quickly compiled the simple TNL example, and notice that if I quickly run the client over and over, the third instance will consistently hang, waiting for the server response to set bQuit, and the server will never receive the client message. Is this normal? What is the preferred way to check for a connection timeout? (The simple example uses EventConnection.)

I was perusing TNLTest to find an answer to this, but it moves straight to GhostConnection, and I'd rather start with firm grasp of what's going on in the simpler base classes.

About the author

Recent Threads


#1
11/05/2004 (8:43 am)
Quickly overriding onConnectTerminate gives the reason code as ReasonRemoteHostRejectedConnection, and the rejection string as "Puzzle"

Is this some sort of flood protection?

Here's my current on connect failure approach:

SafePtr< SimpleEventConnection > newConnection = new SimpleEventConnection;
newConnection->connect(theNetInterface, cmdAddress);

while( newConnection && newConnection->isEstablished() ) {
theNetInterface->checkIncomingPackets();
theNetInterface->processConnections();

}


newConnection will be deleted and set to NULL every time onConnect/ionTerminated is called, right?
#2
11/05/2004 (1:55 pm)
Vector< NetConnection * > abstract = theNetInterface->getConnectionList();

if( abstract.size() ) {
SimpleEventConnection *concrete = dynamic_cast< SimpleEventConnection * >( abstract[0] );
concrete->rpcMessageClientToServer(command.c_str(), 0);
}


I'm trying to run this as the server, but it's giving me Invalid Packet errors. Is this just a Bad Thing? I tried overriding processConnections, but the same thing happened. Must all server to client RPCs be in a response to a client to server RPC?
#3
11/06/2004 (1:48 pm)
How long is the string?

No, RPCs don't imply a certain order.
#4
11/06/2004 (4:08 pm)
The string is 5 characters. I'll post the entire source code on Monday, when I get back to work. Thanks for the quick response, though.
#5
11/07/2004 (10:57 am)
No worries.
#6
11/08/2004 (7:19 am)
Here's the source code that's giving me invalid packet errors.
http://www.cs.virginia.edu/~csz9v/cat/opentnl/simplenet.cpp
#7
11/08/2004 (9:30 am)
Are you running matching binaries for client and server?

Have you tried using the debugger to see what line is throwing the Invalid Packet error?
#8
11/08/2004 (9:59 am)
Yeah, I have matching binaries; a custom build step that copies from one machine to another, and the buildstamp for a sanity check. I checked it with two localhost instances, and it still does the same thing.

Here's where it dies on the client.
// check if the direction this event moves is a valid direction.
if( (evt->getEventDirection() == NetEvent::DirUnset)
|| (evt->getEventDirection() == NetEvent::DirServerToClient && isConnectionToClient())
|| (evt->getEventDirection() == NetEvent::DirClientToServer && isConnectionToServer()) )
{
setLastError("Invalid Packet.");
return;
}

And this is where my face turns red; I didn't realize that the RPCs also enforce direction, even though it's obvious from the declarations :)
#9
11/08/2004 (4:05 pm)
So it works now? :)