Re: [dev] quark and uds

From: Laslo Hunhold <>
Date: Mon, 4 Feb 2019 20:03:56 +0100

On Mon, 04 Feb 2019 18:09:44 +0300
Platon Ryzhikov <> wrote:

Hey Platon,

> Studying quark commit history i found a note that listening on
> UNIX-domain socket was the idea behind its last rewrite.

this was one reason among others. Most importantly, the "old" quark was
heavily architectured around CGI script handling, which was not
implemented in the new version, yielding a much simpler structure.

> This led me to the following questions:

> 1) how should client be organised to use server in this case?

It is very simple really. Let me give you an example with quark and
nc(1) (You will need Netcat OpenBSD for the -U flag, which is available
in all package sources I know).

Let's first fire up quark:

        # quark -U uds_main -d . -l

This will create a UNIX-domain socket file "uds_main" in the current
directory, but you can place it anywhere you like. Just for fun, I set
the serving directory (-d) to the current directory and enabled
directory listing (-l).

The output of ls(1) shows the socket as

        srw-rw-rw- 1 nobody nogroup 0 Feb 4 20:04 uds_main

If you now want to send a request to the server using nc(1), simply
send one to the socket like so:

        echo -n -e "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n" | \
        nc -U udf_main

and netcat will automatically print the response to stdout. That's
it! :)

> 2) which advantages does it grant and how could they be used?

It generally makes it more Unixy and allows you to trivially add
filters in front of quark, e.g. a TLS-interposer, which saves us from
having to add it to quark itself.

This interposer then would accept connections from "outside" and send
them to quark via the UDS. :) It borrows this idea from the ii IRC
client, which makes use of FIFOs that you can directly pipe stuff to.
With UNIX-domain sockets you need a tool like netcat to pipe data from
the command line to it, but it's not a big deal and has many many
possible uses.

I hope this helped!

With best regards


Laslo Hunhold <>

Received on Mon Feb 04 2019 - 20:03:56 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 04 2019 - 20:12:07 CET