From 45f6386784497bdfe3eaa7eb9b8f0104bb804267 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Wed, 30 Sep 2026 05:58:38 +0100 Subject: Say a node's name when pure-serve starts A node's sends are named NAME.OUTPUT, and a receiver's --sender must say that name. Without --name it is the module file's name without .pmod, which nothing said: two board nodes built from board2.aup sent as board2.changed and were refused by receivers expecting a.changed. The first line out now carries the name beside the port and the key, and the usage says where it comes from. --- serve/serve.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'serve/serve.c') diff --git a/serve/serve.c b/serve/serve.c index 319f165..05adf50 100644 --- a/serve/serve.c +++ b/serve/serve.c @@ -2759,8 +2759,11 @@ int main(int argc, char **argv) { return 2; } } - if (*public_key) printf("{\"port\":%u,\"threads\":%u,\"public_key\":\"%s\"}\n", port, threads, public_key); - else printf("{\"port\":%u,\"threads\":%u}\n", port, threads); + /* Its name too: its sends' sources are NAME.OUTPUT, which a receiver's --sender must name. */ + printf("{\"port\":%u,\"threads\":%u,\"name\":\"", port, threads); + for (const char *c = name; *c; ++c) printf(*c == '"' || *c == '\\' ? "\\%c" : "%c", *c); + if (*public_key) printf("\",\"public_key\":\"%s\"}\n", public_key); + else printf("\"}\n"); fflush(stdout); /* A surface reads the owner's snapshots and gives it events. */ if (surface_path && !owned) { fputs("--surface needs an app with states\n", stderr); return 2; } @@ -2855,6 +2858,8 @@ usage: " connection, docs/design/012-link-protocol.md; its key by --seal OUTPUT=KEY)\n" " --send OUTPUT=http[s]://host:port/path: to anything else, over HTTP\n" " --senders FILE: more senders the --link-port takes, a line each: NAME KEY\n" + " --name NAME: the node's name, its sends' sources being NAME.OUTPUT (the module file's name without\n" + " .pmod unless given; the first line out says it)\n" " --memory BYTES: what the app's states may hold (lists' items, texts, sends not yet stored): an event\n" " past it is refused, 503 memory (docs/design/013-memory-budget.md)\n" " --window BYTES: what each --send holds of its sends beyond what its receiver has (and 65,536 sends);\n" -- cgit v1.2.3