摘要: 网络编程1.TCP/UDP特点1.TCP1.面向连接(流式套接字SOCK_STREAM)2.数据完整安全,可靠,有序PS:数据完整不丢失,有序,数据完整采用CRC循环冗余校验,数据不丢失采用重传机制和超时机制,有序的发送端的拆分编号,接收端排序组合。若在某一段时间内接收端到的为两个一样的数据,则选择... 阅读全文
posted @ 2014-06-16 16:19 尾巴草 阅读(186) 评论(0) 推荐(0) 编辑
摘要: echoserver_select.c 1 #include 2 3 #define BACKLOG 10 4 #define PORT 8080 5 #define MAXCLIENT 20 6 #define LEN_BUF 255 7 8 fd_set grset; 9... 阅读全文
posted @ 2014-06-16 16:10 尾巴草 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 三、组播模型muticast.c 1 #include 2 3 #define PORT 8088 4 5 #define MULTIIP "225.0.0.1" 6 7 int main(int argc,char **argv) 8 { 9 if(argc!=2)10 {... 阅读全文
posted @ 2014-06-16 16:04 尾巴草 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 广播模型broadcast.c 1 #include 2 3 #define PORT 8088 4 5 int main(int argc,char **argv) 6 { 7 if(argc!=2) 8 { 9 printf("%s \n",argv[0])... 阅读全文
posted @ 2014-06-16 16:02 尾巴草 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 单播模型echoserver.c 1 #include 2 3 #define PORT 8080 4 #define LEN_BUF 255 5 6 void do_business(int sockfd); 7 8 int main(void) 9 {10 //1.创建sock... 阅读全文
posted @ 2014-06-16 15:59 尾巴草 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 二 文件传输模型 util.c 1 #include 2 3 /** 4 * return value:ret 5 * ret0 @socket is closed by peer 8 */ 9 int readn(int fd,void *buf,size_t len)10 {11 ... 阅读全文
posted @ 2014-06-16 15:12 尾巴草 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 一、基本模型(多进程\多线程) apue.h /usr/include 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #i... 阅读全文
posted @ 2014-06-16 15:07 尾巴草 阅读(165) 评论(0) 推荐(0) 编辑