Instead of writing strings, it's more efficient to use integer command codes (like nix-daemon uses).