Добавил:
Fragga
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:лабораторки по ОС препод Челноков / 2семестр / wi2 / olesha / 3client
.c#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include "fifo.h"
void client(readfd, writefd){
int n;
char buf[MAXSIZE];
char *str1 = "CLIENT READ:";
char *str2 = "CLIENT ECHO FROM SERVER";
//scanf("%s", buf);
write(1, str1, strlen(str1));
read(0, buf, 10);
fsync();
n = strlen(buf);
write(1, buf, n);
write(writefd, buf, n);
fsync();
write(1,str2, strlen(str2));
while((n = read(readfd, buf, BUFSIZ)) > 0)
write(1, buf, n);
fsync();
}
main(){
int fdr, fdw;
fdw = open(FIFO1, O_WRONLY, 0);
fdr = open(FIFO2, O_RDONLY, 0);
client(fdr, fdw);
close(fdr);
close(fdw);
unlink(FIFO1);
unlink(FIFO2);
exit(0);
}