Remote control example
Detroit engine supports remote function calls either over the network or by using a FIFO. This means that every function declared in Ano script can be called remotely. Remote function call is handy in automated testing and such, or programs can be daisy chained to control each other. Remote control support must not be disabled when running configure script (do not use --disable-remote), and remote control must be initialized in Ano script in order it to work.
Procedure remote call can be enabled or disabled by using ANO_REMOTE_FUNCS tag, where each function or callback has either allow or deny keyword. Each function and keyword pair must be quoted. When using remote funcs tag, function remote attribute is not needed.
Example tag what can be put in Ano script header:
; ; @ANO_REMOTE_FUNCS "remote_test = allow", "remote_end = allow", \ ; "remote_forbidden = deny" ;
Compilation
Easiest way to get this example running is to go to examples directory in package root, and run:
$ ./build.sh remote_control
build.sh script compiles Ano script to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.
Preview
; -------------------------------------------------------------------------------
; remote_control.ano
;
; To compile:
;
; $ ./build/ano ./examples/remote_control/remote_control.ano > \
; engine/dsl_ano.h
; -------------------------------------------------------------------------------
;
; @ANO_SCRIPT_NAME remote_control
; @ANO_SCRIPT_VERSION 0.0.2
; @ANO_SCRIPT_DESCRIPTION Example how to run functions remotely
;
; @ANO_FLAGS_USE_PROTOS [ ]
; @ANO_FLAGS_VAR_NAME_SUBS [ ]
; @ANO_FLAGS_VAR_WARN_UNUSED [ ]
;
; Copyright © 2016-2026, Jani Salonen <salojan@goto10.co>
; All rights reserved.
;
; Detroit engine supports remote function calls either over the network or by
; using a FIFO. This means that every function declared in Ano script can be
; called remotely. Remote function call is handy in automated testing and such,
; or programs can be daisy chained to control each other. Remote control
; support must not be disabled when running configure script (do not use
; --disable-remote), and remote control must be initialized in Ano script in
; order it to work.
;
; Procedure remote call can be enabled or disabled by using ANO_REMOTE_FUNCS
; tag, where each function or callback has either allow or deny keyword.
; Each function and keyword pair must be quoted. When using remote funcs tag,
; function remote attribute is not needed.
;
; (at)ANO_REMOTE_FUNCS "remote_test = allow", "remote_end = allow", \
; "remote_forbidden = deny"
;
main {
; This is main program, just start remote thread and let it handle
; remote connections. Program terminates when "remote_end" label is
; called (see below) or <ctrl-c> is pressed.
;
remote_init
}
function remote_test [remote: allow] (param1, param2, param3) {
; To call this function remotely (set SECRET with -na switch):
;
; $ telnet localhost 2109
; SECRET remote_test int:1 uint:2 float:3.3
;
; or by using remotetool:
;
; $ echo 'remote_test 1 2 3' | ./engine/tools/remotetool -na SECRET
;
; End code returned to caller is the sum of params or -1 if error
; occurs.
;
dump param1
dump param2
dump param3
end (param1 + param2 + param3)
}
function remote_end [remote: allow] {
; To call this function remotely (set SECRET with -na switch):
;
; $ telnet localhost 2109
; SECRET remote_end
;
; or by using remotetool:
;
; $ echo 'remote_end' | ./engine/tools/remotetool -na SECRET
;
; Exit code returned to caller is 123.
;
exit (123)
}
function remote_forbidden {
; This function cannot be run remotely, as there is no remote: allow
; attribute.
;
}
; ------------------------------------------------------------------------------ ; remote_control.w2c ; ; To compile: ; ; $ ./build/widget ./examples/remote_control/remote_control.w2c > \ ; engine/widget_defs.h ; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------ ; remote_control.m2c ; ; To compile: ; ; $ ./build/menu ./examples/remote_control/remote_control.m2c > \ ; engine/menu_defs.h ; ------------------------------------------------------------------------------
Copyright © 2026, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.