remote kafka

The official demo,, shows how to run kafka with everything on localhost.
Here are the steps to run kafka server remotely. is the server, which runs kafka zookeeper and brokers on ubuntu in aws
WSL, a windows desktop, runs kafka producer and consumer on WSL ubuntu on local windows

On both AWS and WSL:
download kafka tar ball and extract: 57M
extract to: /mnt/ebs/rio/opensrc/kafka/kafka_2.12-2.3.0
install java. I got OpenJDK 64-Bit Server VM build 11

On AWS, server side:
export KAFKA_OPTS=””
otherwise it’s IPV6
edit so that:
otherwise client report error: Connection to node 0 (localhost/
start zookeepter:
bin/ config/
start server:
bin/ config/

On WSL, client side:
Send message:
bin/ –broker-list –topic test
type some text, ctrlD to exit
Check message received:
bin/ –bootstrap-server –topic test –from-beginning
ctrlC to exit

Roku ECP

Roku TV can be controlled by ECP External Control Protocol.
For example, by running a curl command, a channel can be started or switch to playing another video.
Here are two sample commands:
1. start channel and playing the gym video:
Cmd: curl -d ” ‘’
“contentID=Gym” is to tell channel which piece of video to play once started.
2. while channel is already running, switch to another video, which is dance party.
curl -d ” ‘’

How it is done:
Firmware interpret “launch/dev” as launching the channel whose channel ID is “dev”
Firmware passes {contentId: Gym, type: mp4} to channel entry function Main(args) so that channel knows what to do, e.g. what video to play.
Firmware interpret “input?contentID=Party” as sending {contentID: Party} to the current running channel so that channel, through roInput, knows what to do, e.g. in this case, switching to video called Party.

EcpThe channel source code:
The screen recording:, which show the TV on left, and my linux box on the right.

Range Based For

Range Based For is new in c++11

void RangeBasedFor()
	nullptr_t pN = nullptr;
	void *pV = reinterpret_cast(1);
	int *pI = reinterpret_cast(2);
	void *arr[] = { pV, pN, pI };
	std::cout << "enumerating void *arr[] with Range Based For syntax" << std::endl;
	//other options: auto i, auto&& i
	for (const auto &i : arr) //auto or int, arr can be replaced directly by {2, 3}
		std::cout << i << std::endl;

	std::vector arr2 = { 3, 4 };
	std::cout << "enumerating vector with Range Based For syntax" << std::endl;
	for (const auto &i : arr2) //works for both int[] and vector
		std::cout << i << std::endl;
	std::cout << "enumerating vector with regular for loop" << std::endl;
	for(std::vector::iterator i = arr2.begin(); i != arr2.end(); ++i) //only for vector
		std::cout << *i << std::endl;


enumerating void *arr[] with Range Based For syntax
enumerating vector with Range Based For syntax
enumerating vector with regular for loop


download with pseudo device

These commands were tested in Ubuntu, including WSL

exec 5<> /dev/tcp/
echo -e “GET /riosite/p/exec.txt HTTP/1.0\n” >&5
cat <&5
HTTP/1.1 200 OK
# more info such as server version, date, content type…
FromRioWingNet # this is the content of exec.txt

exec.txt has been downloaded at this point

Here is more investigation:
$ ls /dev/tcp #output: No such file or directory
$ ls -l /dev/fd/5
lrwx—— 1 rio rio 0 Nov 3 17:56 /proc/self/fd/5 -> ‘socket:[43]’
#/dev/fd is a symbolic link to /proc/self/fd
$ echo $$ #output 9
$ ls -l /proc/9/fd/5
lrwx—— 1 rio rio 0 Nov 3 18:05 /proc/9/fd/5 -> ‘socket:[43]’
#fd means file descriptor

Bottom line: the 5 in “exec 5” is the 5 in /proc/9/fd/5