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

I doubt it works that way, try it.
I would if I had a PHP script configured to accept and save a file, but I'm too lazy to do that.

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
Code: [Select]
Transfer-Encoding: chunked

So it's a chunked encoded stream, so each piece of data is prefixed by it's length, then a carriage, then the data itself and then when the data is finished its suffixed by two empty carriages.

« Last Edit: August 09, 2012, 03:06:29 AM by TripNick »

I would if I had a PHP script configured to accept and save a file, but I'm too lazy to do that.
I could do that part.

I'm going to rig up truce's torque webserver so it's compatible with the concept of reading and sending binary data.

I would if I had a PHP script configured to accept and save a file, but I'm too lazy to do that.
I don't ever recall it being possible to upload an image because of null characters.

well that turned out like stuff
http://69.64.43.11:33580/images/img.png
-killing page load times- <--- obvious failure

any ideas?

Code: [Select]
if(fileExt(%page) $= ".png" && !%done && isFile(%server.folder @ %page))
{
%server.debug("> TRYING TO SEND IMAGE");

%this.send("HTTP/1.1 200 OK\r\n");
%this.send("Content-Length: " @ strLen(%body) @ "\r\n");
%this.send("Content-Type: img/png; charset=UTF-8\r\n");
%this.send("Connection: close\r\n");
%this.send("\r\n");

%f = new fileObject();
%f.openForRead("config/pages" @ %page);
while(!%f.isEOF())
{
%this.send(%f.readLine() @ "\r\n");
}
%f.close();
%f.delete();

%done = 1;
}

could I convert the file to base64 (not in torque, mind you) then send that along? i'm not sure how that works.
« Last Edit: August 09, 2012, 07:06:40 PM by Lugnut »

You're going to hit null characters especially in compressed formats like PNG and ZIP files.

You can't do it.

I'm going to rig up truce's torque webserver so it's compatible with the concept of reading and sending binary data.

Are you using the latest version? It should be able to read it just fine (but not send due to Torque's limitations).

Are you using the latest version? It should be able to read it just fine (but not send due to Torque's limitations).
... how long ago did you update last? v2 or something? you added authentication? I'm using that one. i'm fairly certain this is my problem:
You're going to hit null characters especially in compressed formats like PNG and ZIP files.


psst: totally irrelevant, does anyone know anything about the http Connection: Keep-Alive header? could it be used to optimize resource usage and stuff? E: oh dear god that is like night and day in the speed department
« Last Edit: August 09, 2012, 07:30:16 PM by Lugnut »

You're going to hit null characters especially in compressed formats like PNG and ZIP files.

You can't do it.
I have no experience with it but the reason I said what I did is because fileObjects may read as binary, in which case you should be able to send null characters over a tcpconnection as long as you don't turn it into a string, as Lugnut erroneously did.

ok wise man explain how else im supposed to do it

ok wise man explain how else im supposed to do it
It wasn't meant to be an insult. I was just saying you did it wrong.

%tcp.send(%fileObject.readLine(), 0x0A);

... a comma? multiple arguments in send()? what the hell

and i know it wasn't an insult and my post wasn't supposed to come off as if i was implying it was

... a comma? multiple arguments in send()? what the hell
Each argument in tcpObject::send is sent as a different line. 0x0A is the hexadecimal for a new line character.