摘要: 几个I/O相关的函数:#include <unistd.h>ssize_t read(int fd, void *buf, size_t count);ssize_t write(int fd, const void *buf, size_t count);int close(int fd); 为了实现通信,fd可以是套接口(见linux的套接口和管道)的描述符。使用示例如下:#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <errno.h>#inclu 阅读全文
posted @ 2012-06-04 09:11 涵曦 阅读(621) 评论(0) 推荐(0) 编辑
摘要: 创建管道的函数:#include <unistd.h>int pipe(int pipefd[2]); pipefd[0]代表管道读出端的文件描述符,pipefd[1]代表管道写入端的文件描述符。信息只能从pipefd[0]读出,也只能重pipefd[1]写进。所以实现的通信就是单项的,如果要实现双向通信的话可以采用建立两个管道。不过也可以使用套接字通信。因为套接字的通信是双向的。 创建管道的例子:#include <sys/wait.h>#include <stdio.h>#include <stdlib.h>#include <unis 阅读全文
posted @ 2012-06-04 08:39 涵曦 阅读(1430) 评论(0) 推荐(0) 编辑