Echo Server using gnunet-cadet command
I just want to write down this before I forget. I have been working on CADET support for GNUnet++ in the past few days. CADET is not very well documented. The doxygen and comment in headers are really helpful. But a lot of times in order to understand how to use a function, I have to read the source code. This is no exception to the
gnunet-cadet command. Usually the hello world equlivent for any network application would be an echo service (like what
nc can do). The help information of
gnunet-cadet is not very helpful.
Anyway, this is how you do it. First, open a terminal and run the following command to start a CADET server. Note that in CADET the port is specified as a string instead of a number. In this case the port is
❯ gnunet-cadet -o default
In another terminal, first we find our own peer id (the IP address in the GNUnet world). Then connect to the server on the same port (I've modified the peer ID shown so I don't get bombarded with messages from other people). You should see the
gnunet-cadet awaiting for input and the server printing out the message.
❯ gnunet-peerinfo -s I am peer `Z6QYNW5G63KM5DZ8S9V57NXC5F6756Y98NH6CBEQRM12D6FYXHY0'. ❯ gnunet-cadet Z6QYNW5G63KM5DZ8S9V57NXC5F6756Y98NH6CBEQRM12D6FYXHY0
(in the server terminal) * Incoming connection from Z6QYNW5G63KM5DZ8S9V57NXC5F6756Y98NH6CBEQRM12D6FYXHY0
Now type in a message and press enter. You should see the message echoed in the server.
❯ gnunet-cadet Z6QYNW5G63KM5DZ8S9V57NXC5F6756Y98NH6CBEQRM12D6FYXHY0 Hello, World! This is my message 123
(in the server terminal) Hello, World! This is my message 123
Nice! We have a basic server. To create a server on a different port, you change the
-o option. For example, to create a server on port
❯ gnunet-cadet -o i-love-unix
Then append it to the client command to make it use the non-default port:
❯ gnunet-cadet Z6QYNW5G63KM5DZ8S9V57NXC5F6756Y98NH6CBEQRM12D6FYXHY0 i-love-unix
It definitely needs better documentation. And that's exacly why this post. I hope this helps someone.
Systems software, HPC, GPGPU and AI. I mostly write stupid C++ code. Sometimes does AI research. Chronic VRChat addict
I run TLGS, a major search engine on Gemini. Used by Buran by default.
- marty1885 \at protonmail.com
- Matrix: firstname.lastname@example.org
- Jami: a72b62ac04a958ca57739247aa1ed4fe0d11d2df