Author Topic: [RESOURCE] Support_TCPClient v6 (7/16/14)  (Read 3243 times)

This makes TCP connections (both GET and POST) extremely simple. It deals with all of the messy stuff for you, including redirects, reconnection attempts, and error handling. Use it for downloading binary files or text ones.

To use, simple place the code in a file called Support_TCPClient.cs and execute it. Look at the documentation for more details.

Code Here

Documentation Here (recommended read)
« Last Edit: July 16, 2014, 02:28:44 PM by Greek2me »

Nice! I have one of these myself in a module file for one of my old add-ons, but this is much cleaner. I'll be sure to link this to people who ask for help downloading files or sending PHP requests.

Nice! I have one of these myself in a module file for one of my old add-ons, but this is much cleaner. I'll be sure to link this to people who ask for help downloading files or sending PHP requests.

Thanks! All these module-type scripts make life so much easier.

sending PHP requests.
wat
looks good greek.
Thanks! All these module-type scripts make life so much easier.
we could use a lot more, that's for sure

wat

like this:
Code: [Select]
%server = "greekmods.net16.net";
%directory = "/mods/Gamemode_Slayer/stats.php";
%query = "name=" @ $Pref::Player::NetName @
"&version=" @ $Slayer::Version @
"&type=" @ $Slayer::Platform;
TCPClientPOST(%server, %directory, %query);

like this:

That and GET requests. The way Torque encodes the string with HTTPobjects, PHP interprets it so that the first variable contains it's value along with the key-value pairs of the following variables. This allows an easy way to do it with TCP objects so you don't have to deal with the raw request metadata.

Holy stuff, this is amazing! /sticky, no questions asked

Holy stuff, this is amazing! /sticky, no questions asked

doesnt alot of resource threads?


doesnt alot of resource threads?

That's why we have one megatopic which is stickied.

Why not just have a single catch-all "request" method with a configurable method? What if I want to PUT, PATCH, DELETE, OPTIONS, HEAD, TRACE, CONNECT or something else?

It'd be nice if the request method returned an object representing the request (containing the sent headers, method, URI, data sent and the status of the request), and also if, when finished, that a response object would be created as well. It'd contain the received headers, raw response data, etc.




The returned headers can be accessed like this: %tcp.headerField["Content-Type"]