Page 1 of 1

it is possible to send raw data (tcp)

Posted: Fri Jun 08, 2018 4:27 am
by plouf
hollywood has send data but accept string
ho if i wand to send binary data (with a lot of 0 inside data) ?

Re: it is possible to send raw data (tcp)

Posted: Sat Jun 09, 2018 11:47 am
by p-OS
From the documentation:

Code: Select all

In many programming languages a zero character defines the end of the string. Not so in Hollywood. Hollywood allows you to use as many zero characters as you want in your strings. All functions of the string library are zero character safe. For example, this code would return 11: 
 
DebugPrint(StrLen("Hello\0World"))
However, that does not apply to functions that output text. The following example will print "Hello" because of the zero character: 
 
; this will print "Hello" because a zero char terminates the string
DebugPrint("Hello\0World")

Re: it is possible to send raw data (tcp)

Posted: Sat Jun 09, 2018 4:02 pm
by plouf
interensting ...

however i want to sen binary data all values . so this is possible but complicates stuff..

Re: it is possible to send raw data (tcp)

Posted: Sat Jun 09, 2018 5:04 pm
by p-OS
A common way für sending data over the net avoiding problems with specific chars is to encode (und after receiving decode) as base64. Hollywood also has a function for that in string library

Re: it is possible to send raw data (tcp)

Posted: Sat Jun 09, 2018 5:30 pm
by plouf
yeah there are alternatives but require computing power/net traffic
in my case a hardware embedded system is on the other side.... :(

thanx for the help anyway :) it has helped on this

Re: it is possible to send raw data (tcp)

Posted: Sat Jun 09, 2018 5:47 pm
by airsoftsoftwair
You don't have to use Base64. Strings can contain any binary data and you can just send this binary data using SendData(). If you want to put binary data into a string, you can use ByteChr() or read the binary data from a file.

Re: it is possible to send raw data (tcp)

Posted: Sat Jun 09, 2018 6:14 pm
by plouf
ok .. here is an example

value = 3000000

how (easy? ) is to send the data value as 3000000 (value) and not by spliting it to 4 bytes, then inject with bytechr and then send ?

Re: it is possible to send raw data (tcp)

Posted: Wed Jun 13, 2018 5:11 pm
by airsoftsoftwair
Ok, I see what you mean. But it should be really easy to write a function which takes a 32-bit number and returns a string of bytes, e.g.

Code: Select all

Function p_Cvl(v)
	Return(ByteChr((v & $ff000000) >> 24) .. ByteChr((v & $ff0000) >> 16) .. ByteChr((v & $ff00) >> 8) .. ByteChr(v & $ff))
EndFunction
Of course, I could implement a function in Hollywood to easily convert longwords and words to raw bytes if that is of some use...