it is possible to send raw data (tcp)

Find quick help here to get you started with Hollywood
Post Reply
plouf
Posts: 19
Joined: Mon Feb 05, 2018 12:51 am

it is possible to send raw data (tcp)

Post by plouf » Fri Jun 08, 2018 4:27 am

hollywood has send data but accept string
ho if i wand to send binary data (with a lot of 0 inside data) ?

p-OS
Posts: 89
Joined: Tue Nov 02, 2010 12:56 am

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

Post by p-OS » Sat Jun 09, 2018 11:47 am

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")

plouf
Posts: 19
Joined: Mon Feb 05, 2018 12:51 am

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

Post by plouf » Sat Jun 09, 2018 4:02 pm

interensting ...

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

p-OS
Posts: 89
Joined: Tue Nov 02, 2010 12:56 am

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

Post by p-OS » Sat Jun 09, 2018 5:04 pm

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

plouf
Posts: 19
Joined: Mon Feb 05, 2018 12:51 am

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

Post by plouf » Sat Jun 09, 2018 5:30 pm

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

User avatar
airsoftsoftwair
Posts: 2509
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

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

Post by airsoftsoftwair » Sat Jun 09, 2018 5:47 pm

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.

plouf
Posts: 19
Joined: Mon Feb 05, 2018 12:51 am

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

Post by plouf » Sat Jun 09, 2018 6:14 pm

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 ?

User avatar
airsoftsoftwair
Posts: 2509
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

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

Post by airsoftsoftwair » Wed Jun 13, 2018 5:11 pm

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...

Post Reply