Jump to content
  • Advertisement
Sign in to follow this  

OpenTNL Hello World sever crash

This topic is 4156 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

So I'm trying to implement the Hello World app on the OpenTNL website. But it was clearly written for an older version of TNL b/c it won't even compile in it's current state. So I finially got it compiling and running. I run the server, then I run the client. The client connects ok, then tries to do a RPC to the server, and the server crashes. I'm not sure I'm such of fan of the incredibly heavy use of macros in this lib :/ Makes debugging difficult, I can get at whats actually going on. Here's the code:
#include <tnl.h>
#include <tnlEventConnection.h>
#include <tnlNetInterface.h>
#include <tnlRPC.h>
#include <cstdio>
#include <iostream>

using namespace TNL;
using namespace std;

bool gContinue = true;

class MainEventConnection : public EventConnection {
    typedef EventConnection Parent;
    // Identifies this class as a valid network connection
    TNL_DECLARE_NETCONNECTION( MainEventConnection );

    // Declare the client to server message
    TNL_DECLARE_RPC( rpcMessageClientToServer, (StringPtr theMessageString) );

    // Declare the server to client message
    TNL_DECLARE_RPC( rpcMessageServerToClient, (StringPtr theMessageString) );

TNL_IMPLEMENT_NETCONNECTION( MainEventConnection, NetClassGroupGame, true );

// Client to Server RPC
// Meaning the client calls this method on the server
// Essentially the client doing this: server.message( "hello" );
TNL_IMPLEMENT_RPC( MainEventConnection, rpcMessageClientToServer, (StringPtr theMessageString), (theMessageString),
                    NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 0 ) {
    // Display the client's message
    cout << "Client message recieved: ";
    cout << theMessageString << endl;

    StringPtr response = "COMO ESTAS BITCHES!";

    // Send back message to client
    rpcMessageServerToClient( response );

// Server to Client RPC
TNL_IMPLEMENT_RPC( MainEventConnection, rpcMessageServerToClient, (StringPtr theMessageString), (theMessageString),
                   NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0 ) {
    // Display the client's message
    cout << "Server message recieved: ";
    cout << theMessageString << endl;

    gContinue = false;

// ========================================
// ========================================
int main( int nArgs, const char **argsv ) {
    if( nArgs < 3 ) {
        cout << "Ussage: tnltest <-server|-client> <connectAddress>" << endl;
        return 1;

    bool isClient = !strcmp( argsv[1], "-client" );

    // Convert the address into TNL address form
    Address cmdAddress( argsv[2] );

    RefPtr<NetInterface> netInterface;

    if( isClient ) {
        cout << "Is client." << endl;

        Address bindAddress( IPProtocol, Address::Any, 0 );
		MainEventConnection *newConnection = new MainEventConnection;
        netInterface = new NetInterface( bindAddress );

        cout << "Connecting to server..." << endl;
        newConnection->connect( netInterface, cmdAddress );
        cout << "Connection successfull!" << endl;

        StringPtr message = "HOLA!";

        newConnection->rpcMessageClientToServer( message );
        cout << "Message sent: " << message << endl;
    else {
        cout << "Is server." << endl;

        netInterface = new NetInterface( cmdAddress );

        netInterface->setAllowsConnections( true );

    // Listening loop
    while( gContinue ) {

    return 0;

I'm compiling for Win32 using GCC 4.1.2 A side note, when I went to compile OpenTNL, it complained about me using a GCC higher then 3. Infact it wouldn't let me do it. I didn't have the internet so I couldn't get any other compiler. So I hacked the .h files causing the trouble so it would go through with GCC 4 and -fpermissive set. I assume that b/c the library is so old it was developed when GCC 3.x was the latest, so I figured there was a good chance it would still work under GCC 4.x. It compiled fine, but I suppose there is a chance this could be part of the problem?

Share this post

Link to post
Share on other sites
Asking for help for an unspecified crash with no details after compiling an application on an unsupported compiler with self modified headers we have no knowledge of is asking just a tad too much.

The problem can be anywhere. Turn on all the logging you can, then pinpoint down the point of crash.

But yes, like I said, the TNL coding style is far from optimal.

Share this post

Link to post
Share on other sites
er, sorry.

The only mod I did in the header was making it think GCC 4 was GCC 3 and going on from there with that assumption. But your right, this was stupid. I'm going to download GCC 3, give that a try, and try to figure out the OpenTNL logging system.

I just thought maybe someone could see a glaring error I wasn't seeing.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!