(1)client1,基于SIGIO的写法:

1 #include <sys/types.h> 2 #include <sys/stat.h> 3 #include <fcntl.h> 4 #include <unistd.h> 5 #include <signal.h> 6 7 #include <stdio.h> 8 #include <stdlib.h> 9 #include <errno.h> 10 11 #define BUFSIZE 128 12 13 static int fdr; 14 static int fdw; 15 16 static void handler(int unuse) 17 { 18 int ret; 19 char buf[BUFSIZE]; 20 21 ret = read(fdr, buf, BUFSIZE); 22 if (ret == -1) { 23 return; 24 } 25 if (ret == 0) { 26 exit(0); 27 } 28 write(1, "