Game Development Community

Tcpobject

by Patrick Bergeron · in Torque Game Builder · 11/22/2005 (6:55 pm) · 1 replies

I noticed a few posts about the TCPObject class. Has anyone been able to get this object working from within Torque2D? I am assuming you can persist connections. Any samples, tutorials, or more information that could help me get started with this object would be awesome.

Thanks for any help.

#1
11/22/2005 (7:46 pm)
I've used it extensively. I did modify the engine source a bit to tailor it to my needs (mostly adding the ability to do binary file transfers, report connection state, etc.)

I don't have any clean actual-code samples right this second, but the typical init and execution is pretty short. Just something like this:

new TCPObject(TCPConnection);

TCPConnection.connect("someserver.com:80");
TCPConnection.send("Outbound string here\n");

function TCPConnection::onLine(%this, %line)
{
   echo("Incoming line: " @ %line);
}

function TCPConnection::onConnected(%this)
{
   echo("Connected!");
}

function TCPConnection::onDisconnect(%this)
{
   echo("Disconnected!");
}

There are other callbacks for various connection status messages but those are the main three you'll need to get started.