摘要: 1.可以在任意进程(不需要有关系)中进行通信; 2.管道本质是内核中的一块缓存; 3.FIFO在文件系统中存在一个管道文件,管道文件也是和内核中的缓存同步的,是指向文件的路径; 4.命令管道默认是阻塞型; 5.对FIFO的操作跟普通文件一样,可用open打开它,一般的文件I/O函数(close,re 阅读全文
posted @ 2017-03-06 20:16 lvdh1314 阅读(173) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <memory.h>int main(void){ FILE *fp; //命令执行的结果放置在fp指向的结构体缓冲中 fp = popen("cat /etc/passwd","r"); char buf[ 阅读全文
posted @ 2017-03-06 19:27 lvdh1314 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 管道(pipe)、命名管道(FIFO)、信号(signal)、消息队列、共享内存、信号量、套接字(socket) #include <unistd.h>#include <string.h>#include <stdlib.h>#include <stdio.h>/*父进程通过管道传输两个数据给子进 阅读全文
posted @ 2017-03-06 10:29 lvdh1314 阅读(137) 评论(0) 推荐(0) 编辑
摘要: #include <sys/socket.h>#include <netdb.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <signal.h>#include <memor 阅读全文
posted @ 2017-03-05 21:11 lvdh1314 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 广播实现一对多的通信,通过向广播地址发送数据报文实现 只有udp的程序才能广播,tcp不能 #include <sys/socket.h>#include <netdb.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#inclu 阅读全文
posted @ 2017-03-05 21:01 lvdh1314 阅读(146) 评论(0) 推荐(0) 编辑
摘要: #include <sys/socket.h>#include <netdb.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <signal.h>#include <memor 阅读全文
posted @ 2017-03-05 20:31 lvdh1314 阅读(1156) 评论(0) 推荐(0) 编辑
摘要: 在/etc/hosts中已经设置了ip与域名的映射关系,通过域名解析函数进行解析(主机名,别名,协议类型,网络地址大小,指向网络IP地址指针等) 部分解析函数: #include<netdb.h> struct hostent gethostbyname(const char *hostname); 阅读全文
posted @ 2017-03-05 20:17 lvdh1314 阅读(149) 评论(0) 推荐(0) 编辑
摘要: #include <sys/socket.h>#include <netdb.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <signal.h>#include <memor 阅读全文
posted @ 2017-03-05 10:21 lvdh1314 阅读(201) 评论(0) 推荐(0) 编辑
摘要: #include <sys/socket.h>#include <netdb.h>#include <unistd.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <signal.h>#include <time. 阅读全文
posted @ 2017-03-05 10:03 lvdh1314 阅读(237) 评论(0) 推荐(0) 编辑
摘要: arm-none-linux-gnueabi-gcc -o tcp_service tcp_service.c 由于使用的是交叉编译环境,生成的目标代码是用于arm开发板,故在x86电脑上无法使用。 阅读全文
posted @ 2017-02-28 19:45 lvdh1314 阅读(275) 评论(0) 推荐(0) 编辑