ref: 5a6a10aba73281e44d2553cfcbce7ff40a581e00
dir: /eatplumb.c/
#include <u.h> #include <libc.h> #include <plumb.h> void usage(void) { fprint(2, "usage: %s port\n", argv0); exits("usage"); } void main(int argc, char *argv[]) { int fd; char *port; Plumbmsg *m; ARGBEGIN{ default: usage(); }ARGEND; if(argc != 1) usage(); port = argv[0]; if((fd = plumbopen(port, OREAD)) < 0) sysfatal("plumbopen: %r"); fprint(2, "listening on \"%s\"\n", port); for(;;){ if((m = plumbrecv(fd)) == nil) sysfatal("plumbrecv: %r"); print("* [%s] %s\n", port, m->data); plumbfree(m); } }