Blockland Forums > Modification Help

TCP Objects

Pages: (1/7) > >>

jes00:

Could someone teach me how to use client sided TCP objects?

Fluff-is-back:

Totally explaining these would take a long time. What are you trying to do? Then we can provide you with an example and an explanation.

jes00:


--- Quote from: Fluff-is-back on April 04, 2012, 09:40:07 AM ---Totally explaining these would take a long time. What are you trying to do? Then we can provide you with an example and an explanation.

--- End quote ---
Get a line of text from a website.

Fluff-is-back:

Then it would probably better for you to use HTTPObjects:


new HTTPObject(GetThePage).get("google.com", "/file.txt"); // Create the HTTPObject and tell it to fetch the page "google.com/file.txt

function GetThePage::onLine(%this, %line)
{
    %this.page = %this.page NL %line; // Once we get a response, for every line we get, we want to add it all into a single buffer
}

function GetThePage::onDisconnect(%this)
{
    doStuffWithPage(%this.page); // The server has disconnected us, we therefore have the whole page stored in %this.page
}


Wordy:


--- Quote from: Fluff-is-back on April 04, 2012, 10:03:05 AM ---Then it would probably better for you to use HTTPObjects:


new HTTPObject(GetThePage).get("google.com", "/file.txt"); // Create the HTTPObject and tell it to fetch the page "google.com/file.txt

function GetThePage::onLine(%this, %line)
{
    %this.page = %this.page NL %line; // Once we get a response, for every line we get, we want to add it all into a single buffer
}

function GetThePage::onDisconnect(%this)
{
    doStuffWithPage(%this.page); // The server has disconnected us, we therefore have the whole page stored in %this.page
}


--- End quote ---

So lets say I wanted to retrieve something from my website which is in txt format, lets say www.wordie.co.cc/text.html - it'll return with the text which I have wrote on it?

Pages: (1/7) > >>

Go to full version