Problem: TCPObj not going binary. Script included for reference.
by Stefan Lundmark · in Torque Game Engine · 04/12/2004 (2:58 pm) · 4 replies
I'm trying to get a system into my Torque Menu where the user can download a patch.
I've ran into problems where TCPObj is corrupting my files that are sent.
This is how the actual script looks like.
When a file is sent with this script. It downloads, and is saved to disk. The file seems to lose it's icon and can't be executed. It's also impossible to delete this file, it says it's in use.
How would I proceed to FORCE it into binary mode?
I've tried Dylan Sale's resource on how to make it go Binary but as I've already applied it it does not seem to make it.
I've tried to enable the thing in the code by issuing this:
Of course that didn't work either :P
So I'm asking the community for help.
Thanks in advance.
I've ran into problems where TCPObj is corrupting my files that are sent.
This is how the actual script looks like.
Quote:Executes the code below.
getpatch("192.168.0.4","80","/game/patches/latestpatch.exe","data/latestpatch.exe");
function GetPatch(%site,%port,%filepath,%saveTo)
{
new TCPObject(Patch);
Patch.site = %site;
Patch.port = %port;
Patch.saveTo = %saveTo;
Patch.filepath = %filePath;
Patch.connect(Patch.site@":"@Patch.port);
echo ("Connecting");
Patch.setBinary(true);
}
function Patch::onConnected(%this)
{
echo ("Downloading...");
Patch.send("GET "@%this.filePath@" HTTP/1.1\nHost: "@%this.site@"\nUser-Agent: Torque/1.0 \n\r\n");
}
function Patch::onDisconnect(%this)
{
Patch.saveBufferToFile(Patch.saveTo);
echo ("Done!");
}
function Patch::onConnectFailed()
{
echo ("Connection Failed.");
}When a file is sent with this script. It downloads, and is saved to disk. The file seems to lose it's icon and can't be executed. It's also impossible to delete this file, it says it's in use.
How would I proceed to FORCE it into binary mode?
I've tried Dylan Sale's resource on how to make it go Binary but as I've already applied it it does not seem to make it.
I've tried to enable the thing in the code by issuing this:
Quote:isBinary = true;
Of course that didn't work either :P
So I'm asking the community for help.
Thanks in advance.
About the author
#2
So, when do I want to save the buffer to avoid the response header?
I absolutely no clue how to do that.
04/13/2004 (6:15 am)
You might be correct, but that's how the example files in Dylan Sale resource looks like too and it obviously works.So, when do I want to save the buffer to avoid the response header?
I absolutely no clue how to do that.
#3
Basically what he does is use the onLine() callback to strip out the header before switching to binary mode and saving the binary data.
04/13/2004 (6:21 am)
Stefan I think you need to look over Dylan's example some more. You are missing large chunks of it.Basically what he does is use the onLine() callback to strip out the header before switching to binary mode and saving the binary data.
#4
04/13/2004 (1:24 pm)
I found out what the problem was. I'm using TGElobby to connect with a IRC client. To make that work, I disabled binary mode.
Torque Owner Harold "LabRat" Brown
That is going to include the response header to the HTTP Get