it is possible to send raw data (tcp)

Find quick help here to get you started with Hollywood
Post Reply
plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

it is possible to send raw data (tcp)

Post by plouf »

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: 123
Joined: Mon Nov 01, 2010 11:56 pm

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

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

plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

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

Post by plouf »

interensting ...

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

p-OS
Posts: 123
Joined: Mon Nov 01, 2010 11:56 pm

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

Post 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

plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

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

Post 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

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

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

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

plouf
Posts: 109
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

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

Post 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 ?

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

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

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

Post Reply