From 1a47d20fe2ccc21513511f5fb909149a719fe61e Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Fri, 1 May 2026 09:49:05 +0200 Subject: [PATCH] Pass remote host name on command line. The default is localhost. Usage: netmem_cache [] pdp6 [-m ] [-p ] --- netmem_cache/netmem_cache.c | 9 +++++++-- pdp6/main.c | 25 +++++++++---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/netmem_cache/netmem_cache.c b/netmem_cache/netmem_cache.c index 6ff4158..ec38426 100644 --- a/netmem_cache/netmem_cache.c +++ b/netmem_cache/netmem_cache.c @@ -4,6 +4,8 @@ #include #include +static const char *host = "localhost"; + enum { WRRQ = 1, @@ -252,7 +254,7 @@ handlecon(int confd, void *arg, int port) { memfd = confd; printf("connected to pdp-6 %d\n", memfd); - int fd = dial("maya", 10006); + int fd = dial(host, 10006); if(fd < 0) goto discon; printf("connected fd %d\n", fd); @@ -267,13 +269,16 @@ printf("connected fd %d\n", fd); } int -main() +main(int argc, char **argv) { static struct PortHandler port20006 = { .port = 20006, .handle = handlecon } ; + if (argc > 1) + host = argv[1]; + serveN(&port20006, 1, NULL); return 0; diff --git a/pdp6/main.c b/pdp6/main.c index 1814991..d3025bc 100644 --- a/pdp6/main.c +++ b/pdp6/main.c @@ -352,15 +352,13 @@ netthread(void *arg) return nil; } -/* char *argv0; void usage(void) { - fprintf(stderr, "usage: %s [-h host] [-p port]\n", argv0); + fprintf(stderr, "usage: %s [-m host] [-p port]\n", argv0); exit(1); } -*/ static void cleanup(void *arg) @@ -383,23 +381,19 @@ main(int argc, char *argv[]) Panel *panel; PDP6 pdp6, *pdp = &pdp6; -/* - const char *host; - int port; + const char *mhost = "localhost"; + int mport = 20006; - host = "localhost"; - port = 3400; ARGBEGIN { - case 'h': - host = EARGF(usage()); + case 'm': + mhost = EARGF(usage()); break; case 'p': - port = atoi(EARGF(usage())); + mport = atoi(EARGF(usage())); break; default: usage(); } ARGEND; -*/ panel = getpanel(); if(panel == nil) { @@ -448,13 +442,12 @@ main(int argc, char *argv[]) -// pdp->netmem_fd.fd = dial("maya", 10006); -/* - pdp->netmem_fd.fd = dial("maya", 20006); + pdp->netmem_fd.fd = dial(mhost, mport); if(pdp->netmem_fd.fd >= 0) printf("netmem connected\n"); + else + printf("netmem not connected\n"); waitfd(&pdp->netmem_fd); -*/ void initlua(PDP6 *pdp); initlua(pdp);