Hello Libixp
These series of examples aims to serve as a brief introduction to 9P (synthetic) file servers with libixp 0.5. Every example is a different tag in a mercurial repository, starting with a very simple Hello world file server -called hi- that is progressively extended.
See also: intro(5), 9p.cat-v.org, examples/ixpsrv.c, m9u, wmii
Hello world
This is one of the simplest possible file sirvers. It serves a directory containing only one file, msg, that returns the string "Hello world!" when read.
Once libixp is installed hi can be compiled running: make
and executed with the hi command. The hi 9P server can then be mounted (for example, from a local 9vx instance), or accessed directly with ixpc:
% ./hi &
% ixpc -a 'unix!/path/to/hi' ls /
msg
% ixpc -a 'unix!/path/to/hi' read /msg
Hello world!
Alternatively to the -a option, the address can be given as an environment variable ($IXP_ADDRESS). The following examples will assume that such variable has been set.
Msg
Before adding the possibility to write to the msg file, we have to modify hi to handle arbitrary messages, removing all the hard-coded Hello world values. This new version adds a command line option -m to set the message in the msg file:
% ./hi -m 'Hola mundo!' &
% ixpc read msg
Hola mundo!
Wmsg
Allowing writting to the msg, the "Hello world!" string can be modified from the client side. This simple program already have the power to be used as a platform-independent, network-transparent IPC system:
%./hi -m Ciao &
%ixpc read /msg
Ciao
%ixpc xwrite /msg 'Salve mondo!'
%ixpc read /msg
Salve mondo!
Msgsys
IN PROGRESS
Several clients can connect to the hi 9P server at the same time. The clients can store different messages in the msg server, but still have the possibility to see the messages by other clients (as rio(1) does with wsys/).