Цитата(bilbobagginz @ 8.1.2007, 20:37 ) | http://www.linuxhq.com/guides/LPG/node7.html (англ.) с примерами |
Большое тебе спасибо !!! нашел что искал. Точнее через pipe передал данные, теперь буду думать толи мне надо =))
Добавлено @ 14:11
| Код | /***************************************************************************** Excerpt from "Linux Programmer's Guide - Chapter 6" (C)opyright 1994-1995, Scott Burkett ***************************************************************************** MODULE: fifoserver.c *****************************************************************************/
#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <unistd.h>
#include <linux/stat.h>
#define FIFO_FILE "MYFIFO"
int main(void) { FILE *fp; char readbuf[80];
/* Create the FIFO if it does not exist */ umask(0); mknod(FIFO_FILE, S_IFIFO|0666, 0);
while(1) { fp = fopen(FIFO_FILE, "r"); fgets(readbuf, 80, fp); printf("Received string: %s\n", readbuf); fclose(fp); }
return(0); } Since a FIFO blocks by default, run the server in the background after you compile it:
$ fifoserver& We will discuss a FIFO's blocking action in a moment. First, consider the following simple client frontend to our server:
/***************************************************************************** Excerpt from "Linux Programmer's Guide - Chapter 6" (C)opyright 1994-1995, Scott Burkett ***************************************************************************** MODULE: fifoclient.c *****************************************************************************/
#include <stdio.h> #include <stdlib.h>
#define FIFO_FILE "MYFIFO"
int main(int argc, char *argv[]) { FILE *fp;
if ( argc != 2 ) { printf("USAGE: fifoclient [string]\n"); exit(1); }
if((fp = fopen(FIFO_FILE, "w")) == NULL) { perror("fopen"); exit(1); }
fputs(argv[1], fp);
fclose(fp); return(0); }
|
эм.. не всё так просто.
1. Как сделать что бы client не ждал отправки если сервер я не включил, допустим отправил в "файл" и всё ?
2. Как сделать что бы сервер не ждал ввода, а проверил ввод и пошел дальше, проверил дальше по циклу ? |