LINUX 管道通信问题
本人刚刚接触这些,不太懂,话说LINUX 的库函数 应该有 SDK吧? 在哪。。类似 MSDN 样的。。。
话不多说 直接上代码
#include <sys/types.h>#include <sys/stat.h>#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#define FIFO "/myfifo"int main(int argc, char** argv){ int fd; char w_buf[100]; int nwrite; if(fd == -1) { if(errno == ENXIO) { printf("open error; no reading process\n"); } } fd = open(FIFO,O_WRONLY|O_NONBLOCK,0); strcpy(w_buf,"1111111111111111111111111111111111"); if((nwrite = write(fd,w_buf,100)) == -1) { printf("write wrong: %d \n",nwrite); if(errno == EAGAIN) { printf("The FIFO has not been read yet,Please try later\n"); } }else { printf("write %s to the FIFO \n",w_buf); } return 1;}