Hi Everyone,
I would like to send data binary with the NDK Webserver.
Unfortunately it is not possible to use the "httpSendClientStr" function, because the functions is calculating the send buffer size according the first 0 or '\0'.
How then can I send binary Data?
Thanks in Advance.
Best Regards
Chris
My C Code on the TM4C:
struct BINDATA
{
int32_t a;
int32_t b;
int32_t c;
};
Int getBinData(SOCKET htmlSock, int ContentLength, char *pArgs)
{
struct BINDATA bd;
bd.a = 77;
httpSendStatusLine(htmlSock, HTTP_OK, CONTENT_TYPE_HTML);
httpSendClientStr(htmlSock, CRLF);
httpSendFullResponse(htmlSock, HTTP_OK, (char*)&bd);
return (1);
}
My Client JavaScript Code:
function getBinary() {
var oReq = new XMLHttpRequest();
oReq.open("GET", "192.168.1.102/binData.cgi", true);
oReq.responseType = "arraybuffer";
oReq.onload = function (oEvent) {
var arrayBuffer = oReq.response; // Note: not oReq.responseText
if (arrayBuffer) {
var byteArray = {};
byteArray = new Int32Array(arrayBuffer);
data.insertRows(data.getNumberOfRows(), [
[++ii, byteArray[0], byteArray[1]]
]);
}
};
oReq.send(null);
}