send.c (483B)
1 #include <u.h> 2 #include <libc.h> 3 #include <plumb.h> 4 5 #include "sendreceive.h" 6 7 char buf[BufSize]; 8 9 char *port = DefaultPort; 10 11 void 12 main(int argc, char **argv) 13 { 14 ARGBEGIN { 15 case 'p': 16 port = ARGF(); 17 break; 18 } ARGEND 19 20 int pd; 21 22 Plumbmsg msg = (Plumbmsg){ 23 "send", 24 port, 25 nil, 26 "text", 27 nil, 28 0, 29 buf 30 }; 31 32 pd = plumbopen("send", OWRITE); 33 if (pd <= 0) sysfatal("no plumber: %r"); 34 while ((msg.ndata = read(0, buf, BufSize)) > 0) { 35 plumbsend(pd, &msg); 36 } 37 close(pd); 38 }