Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 12:43:11 +0000



[Programming Help] - How access the binary from sc.MakeHTTPBinaryRequest()

View Count: 486

[2023-02-14 13:25:54]
User305536 - Posts: 52
Hello,
I have used sc.MakeHTTPBinaryRequest() to obtain the binary data.

The contents of this I am trying to eventually get to use this data in a call to Assembly.Load(sc.HTTPBinaryResponse);

The documentation says This response sc.HTTPBinaryResponse is a SCConstCharArray type and holds an array of bytes/characters


However, I have no idea about how to access the data in this c_ArrayWrapper. I have looked at scstructures.h but
do not see how I can access the binary data from this structure.

Is there a class or function I can call to get it?
How do I get to the contents?
How big is this array?

Thank you,
Allan
[2023-02-14 16:59:05]
User305536 - Posts: 52
The goal of using sc.MakeHTTPBinaryRequest() is to store binary dll
which later is loaded to make the exported functions in the dll available.

I tried
HMyCustomDll = LoadLibrary( (LPCSTR)sc.HTTPBinaryResponse);          

but get cannot convert from 'SCConstCharArray' to 'LPCSTR'

The problem is not understanding how to access the binary data and
use either LoadLibrary or Assembly.Load (not sure) to mthen make it avaiable inside Sierrachart.

Help in understanding how to access the data is appreciated.

Allan
[2023-02-14 18:46:13]
User305536 - Posts: 52
I am finding out that I probably need to save the array buffer sc.HTTPBinaryResponse out to file.

How can I access the sc.HTTPBinaryResponse buffer to write it out to file?

Thank you,
Allan
[2023-02-15 04:56:08]
User305536 - Posts: 52
THE PROBLEM here is that I don't know how to access the binary data thats stored in the sc.HTTPBinaryResponse
Please help, I love Sierra Chart and am long time user, but there is literally zero documentation on a beautiful feature.
This sc.MakeHTTPBinaryRequest really scratches my itch, but accessing the binary data is killing me.
std::string outputfile1;
std::ofstream myfile1;
outputfile1 = "C:\\temp\\mytest.bin";

myfile1.open(outputfile1, std::ios::out | std::ios::trunc);
//now loop thru
for(int i = 1; i <= sc.HTTPBinaryResponse.GetArraySize(); i++)
{
  if (sc.HTTPBinaryResponse)
  {
    Msg.Format("INDEX IS: %i", i);
    sc.AddMessageToLog(Msg, 0);
    myfile1 << sc.HTTPBinaryResponse << std::endl;
  }
}

//myfile1 << "Start Debug logging..." << std::endl;
//myfile1 << (const char *) &sc.HTTPBinaryResponse;
myfile1.close();

[2023-02-15 08:45:34]
User907968 - Posts: 824
accessing the binary data is killing me

You can access via pointer to start of data - sc.HTTPBinaryResponse.GetPointer()
or via array operator - sc.HTTPBinaryResponse[]
[2023-02-15 14:22:18]
User305536 - Posts: 52
Well I have tried BOTH of these without success. Please provide concrete example of their use.

Thank you
[2023-02-15 14:24:47]
User305536 - Posts: 52
For example using the pointer without knowing the size of the data will read TOO MUCH or TOO LITTLE of the data in memory. It will actually read memory from anywhere in the computer!
[2023-02-15 14:49:57]
User907968 - Posts: 824
without knowing the size of the data
sc.HTTPBinaryResponse.GetArraySize()

The data type is char you can get the arraysize therefore you can see exactly the maximum amount of data to read.
Date Time Of Last Edit: 2023-02-15 14:50:13
[2023-02-15 15:14:10]
User305536 - Posts: 52
Yes I found that one too, but maybe I really am just stupid but I just cant get any output.
do you have a working example?
[2023-02-15 15:19:45]
User907968 - Posts: 824
First question, does the response actually contain anything?


if (sc.HTTPBinaryResponse.GetArraySize() == 0)
return;

for (auto i = 0; i < sc.HTTPBinaryResponse.GetArraySize(); ++i)
{
auto c = sc.HTTPBinaryResponse[i];

// do some stuff here maybe write the char to the message log
// or inspect the data with your debugger attached

}

[2023-02-15 16:26:26]
User305536 - Posts: 52
well a binary stream was sent to sc.MakeHTTPBinaryRequest. Its a dll and I used mime type application/octet-stream

maybe I should have used a different type not sure.
[2023-02-16 06:50:47]
User305536 - Posts: 52
Ok I do appreciate your looking into this. Eventual solution which works well for me is libcurl.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account