From ba066c34dde204aa192d03a23a81356374d93731 Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 7 Apr 1993 11:50:31 +0000 Subject: Initial revision --- comm/OLD/porttest.cc | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 comm/OLD/porttest.cc (limited to 'comm/OLD/porttest.cc') diff --git a/comm/OLD/porttest.cc b/comm/OLD/porttest.cc new file mode 100644 index 0000000..c73268d --- /dev/null +++ b/comm/OLD/porttest.cc @@ -0,0 +1,72 @@ +/* + * The Unix Channel + * + * by Michel Beaudouin-Lafon + * + * Copyright 1990-1993 + * Laboratoire de Recherche en Informatique (LRI) + * + * Port server: test program + * + * $Id$ + * $CurLog$ + */ + +#include "PortServer.h" + +#include +#include +#include + +int +fMatch (const char* match, lword host, sword port, const char*) +{ + printf ("0x%lx:%d -> %s\n", host, port, match); + return 1; +} + +main (int argc, char **argv) +{ + char *host = 0; + char *service = "portserv"; + + if (argc > 1 && argv [1] [0] == ':') { + host = argv [1] + 1; + argc--, argv++; + } + if (argc > 1 && argv [1] [0] == '=') { + service = argv [1] + 1; + argc--, argv++; + } + UchPortServer ps (service, host); + + switch (argc) { + case 1: + ps.Dump (); + break; + case 2: + if (strcmp (argv [1], "quit") == 0) + ps.Quit (); + else + if (argv [1] [0] == '?') + ps.Match (argv [1] + 1, fMatch); + else { + UchInetAddress* addr = ps.Inquire (argv [1]); + if (addr) { + printf ("0x%lx:%d\n", addr->Host (), addr->Port ()); + delete addr; + } else + printf ("not found\n"); + } + break; + case 3: { + UchInetAddress addr ("", atoi (argv [2])); + if (argv [1] [0] == '-') + ps.Remove (argv [1] + 1, addr, 987); + else + ps.Register (argv [1], addr, 987); + break; + } + } +} + -- cgit v1.1