diff -r 9b64437262a2 -r 864f59271974 src/main.c --- a/src/main.c Sun Mar 29 13:26:00 2026 +0200 +++ b/src/main.c Sun Mar 29 15:17:28 2026 +0200 @@ -37,14 +37,16 @@ #include #include #include +#include int get_settings(int argc, char **argv, Settings *settings) { char *valid; unsigned long int time, port; uint8_t timeunit = 60; size_t len; + bool port_set = false; - for (int opt ; (opt = getopt(argc, argv, "a:bc:Fhp:rsS:t:Uv")) != -1 ;) { + for (int opt ; (opt = getopt(argc, argv, "a:bc:Fhp:rsS:t:uUv")) != -1 ;) { switch (opt) { case 'c': settings->continuepgn = optarg; @@ -61,6 +63,14 @@ case 'F': settings->disableflip = true; break; + case 'u': + if (port_set) { + fprintf(stderr, "Cannot use Unix domain sockets " + "when a TCP port was specified.\n"); + return 1; + } + settings->usedomainsocket = true; + break; case 'U': settings->unicode = false; break; @@ -87,6 +97,15 @@ } break; case 'p': + if (port_set) { + fprintf(stderr, "Cannot use -p twice.\n"); + return 1; + } + if (settings->usedomainsocket) { + fprintf(stderr, "Cannot specify TCP port " + "when using Unix domain sockets.\n"); + return 1; + } port = strtol(optarg, &valid, 10); if (port < 1025 || port > 65535 || *valid != '\0') { fprintf(stderr, @@ -96,6 +115,7 @@ return 1; } else { settings->port = (short) port; + port_set = true; } break; case 'v': @@ -111,6 +131,7 @@ " -c Continue the specified game\n" " -h This help page\n" " -p TCP port to use (default: 27015)\n" +" -u Use Unix domain socket instead of TCP\n" " -U Disables unicode pieces\n" " -v Print version information and exits\n" "\nServer options\n" @@ -119,13 +140,16 @@ " -r Distribute color randomly\n" " -t