Author Topic: TCPObject Saving binary data of unknown length  (Read 5474 times)

Yay, it works. It doesn't work all of the time, but it works more than it doesn't

My only suggestion is to remove that whitespace at the bottom, besides that it looks great.

please release this, jesus.
I wanna know how you managed to download... what are they? png's?

Coding help topic slowly morphs into modification discussion topic
Make the preview bigger

please release this, jesus.
I wanna know how you managed to download... what are they? png's?
Yes, in a much simplified way:

Code: [Select]
new tcpObject() { className = imgDownloader; };

function imgDownloader::onConnected(%this)
{
%this.send("GET /detail.php?q= " @ strReplace(strReplace(%this.ip,".","-"),":","_") SPC "HTTP/1.1\r\nHost:image.blockland.us\r\n\r\n");
}

function imgDownloader::onLine(%this, %line)
{
if(%line $= "") //end of headers
%this.setBinary(1);
}

function imgDownloader::onBinChunk(%this)
{
cancel(%this.schedule);
%this.schedule = schedule(1000,saveBufferToFile,"config/preview.png");
}

function imgDownloader::downloadImg(%this, %ip)
{
%this.setBinary(0);
%this.ip = %ip;
%this.connect("image.blockland.us:80");
}
« Last Edit: August 08, 2012, 05:18:15 PM by TripNick »

does this ignore the problem of nullcharacters not able to be stored in torque strings?

does this ignore the problem of nullcharacters not able to be stored in torque strings?
It doesn't store them in torque strings so yes.

-snip-
That code will not work for blockland server previews. Theres a "2000" line right after the blank line for the headers that if saved with the image it will corrupt it. actually, it is possible your code might work but mine didnt unless i skipped that

It doesn't store them in torque strings so yes.
YES
That code will not work for blockland server previews. Theres a "2000" line right after the blank line for the headers that if saved with the image it will corrupt it. actually, it is possible your code might work but mine didnt unless i skipped that
IF(%LINE $= "2000")
CONTINUE;


wow that was hard

that came off mean, didn't mean for it to seem rude. that's not a hard bypass, but thank you for telling me that, it would've bit me in the ass.

is that, perhaps, the length?
« Last Edit: August 08, 2012, 06:22:31 PM by Lugnut »

Ok, then change the check to check for after the 2000 line. I've done 0 research into server previews aside from when they first came out.

IF(%LINE $= "2000")
CONTINUE;
actually you'll want that to setBinary(1); not continue, setBinary(1) is what makes it save it into the c++ buffer.

wat. i wasnt tryin to be mean to anyone i was just putting it out there cause it was an ass pain for me to figure out why the forget it was corrupted every time. but no its not the length. no idea wtf it is

can you SEND images this way somehow?
for example, a webserver hosting images?
wat. i wasnt tryin to be mean to anyone i was just putting it out there cause it was an ass pain for me to figure out why the forget it was corrupted every time. but no its not the length. no idea wtf it is
no, i was being mean with my
wow that was hard
bit
Ok, then change the check to check for after the 2000 line. I've done 0 research into server previews aside from when they first came out.
actually you'll want that to setBinary(1); not continue, setBinary(1) is what makes it save it into the c++ buffer.
k
was thinking for() loops

I am fairly certain that you can post images to a server.

I am fairly certain that you can post images to a server.
It's impossible.

It's impossible.
I'm not 100% sure but I think fileObjects read from binary so you may be able to send their binary data through a TCP object as long as you don't store it in a variable any time between.

I'm not 100% sure but I think fileObjects read from binary so you may be able to send their binary data through a TCP object as long as you don't store it in a variable any time between.
I doubt it works that way, try it.