新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
進程通信(命名管道單向通信)
client.c: 1 #include2#include 3#include 4#include 5#include 6#include 7#include 8#define _PATH_ "./tmp" 9#define SIZE 100 10int main() 11 { 12 if(mkfifo(_PATH_,0666|S_IFIFO)<0) 13 { 14 perror("mkfifo"); 15 return -1; 16 } 17 intfd=open(_PATH_,O_WRONLY); 18 if(fd<0) 19 { 20 perror("open"); 21 return -1; 22 } 23 char buf[SIZE]; 24 memset(buf,'\0',SIZE); 25 while(1) 26 { 27 scanf("%s",buf); 28 write(fd,buf,strlen(buf)); 29 } 30 close(fd); 31 return 0; 32 } server.c: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7#include 8#define _PATH_ "./tmp" 9#define SIZE 100 10int main() 11 { 12 intfd=open(_PATH_,O_RDONLY); 13 if(fd<0) 14 { 15 perror("open"); 16 return -1; 17 } 18 char buf[SIZE]; 19 while(1) 20 { 21 22 memset(buf,'\0',SIZE); 23 read(fd,buf,sizeof(buf)); 24 printf("%s\n",buf); 25 } 26 close(fd); 27 return 0; 28 } Makefile: 1.PHONY:all 2 all:client server 3 server:server.c 4 gcc -o $@ $^ 5client:client.c 6 gcc -o $@ $^ 7.PHONY:clean 8clean: 9 rm -f client server tmp
創(chuàng)新互聯(lián)公司的客戶來自各行各業(yè),為了共同目標(biāo),我們在工作上密切配合,從創(chuàng)業(yè)型小企業(yè)到企事業(yè)單位,感謝他們對我們的要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。專業(yè)領(lǐng)域包括網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、電商網(wǎng)站開發(fā)、微信營銷、系統(tǒng)平臺開發(fā)。
本文題目:進程通信(命名管道單向通信)
網(wǎng)站網(wǎng)址:http://fisionsoft.com.cn/article/jpgesj.html