![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linux网络编程
One Piece&
这个作者很懒,什么都没留下…
展开
-
Linux网络编程中出现 listen fail : Socket operation on non-socket错误
错误代码:int main (int argc,char *argv[]){ int lfd = 0,cfd = 0; /* 定义服务器地址结构 和 客户端地址结构*/ struct sockaddr_in ser_addr,cli_addr; /* 客户端地址结构大小*/ socklen_t cli_addr_len; char cli_ip[1024],buf[1024]; /*地址结构 ip+端口号*/ ser_addr.sin原创 2020-08-30 23:03:49 · 1187 阅读 · 0 评论 -
Linux网络编程 1 写一个tcp服务器,实现字母的大小写转换(附详细注释)
服务器端代码:#include <stdio.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <errno.h>#include <pthread.h>/* 1原创 2020-08-30 22:53:15 · 651 阅读 · 0 评论 -
select、poll和epoll,各自的实现原理、创建流程、优缺点以及注意事项
多路IO转接服务器也叫做多任务IO服务器。该类服务器实现的主旨思想是:不再由应用程序自己监视客户端连接,取而代之由内核替应用程序监视文件。select:1、实现原理可以假想,一个老板(服务器),雇佣一个秘(select)。之前老板需要事事亲力亲为,现在只需要管理好秘书就行了,其他的事情都由秘书去管理其他人(客户端)完成。这个select机制,是由内核提供的。之前的多进程、多线程并服务器是通过一个lfd,通过lfd引导,建立多个cfd。运行没有什么问题,只是单纯的为了提高效率,引入了多路io转接服务原创 2020-09-01 13:41:50 · 660 阅读 · 0 评论 -
Linux网络编程 6 多路io转接服务器 (epoll服务器) 附详细的注释和扩展
server.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>#include <errno.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>#include原创 2020-09-01 12:35:54 · 156 阅读 · 0 评论 -
Linux网络编程 5 多路IO转接服务器(select服务器)附详细注释和相关扩展
服务器端 server.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>#include <errno.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>#i原创 2020-08-31 22:30:05 · 167 阅读 · 0 评论 -
Linux网络编程 4 多线程并发服务器
服务器端:mult_thread.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>#include <errno.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>原创 2020-08-31 18:09:24 · 173 阅读 · 0 评论 -
Linux网络编程 3 多进程并发服务器 (附详细分析注释)
服务器端:mult_ser.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>#include <errno.h>#include <unistd.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>#原创 2020-08-31 15:14:03 · 257 阅读 · 0 评论 -
Linux网络编程 2 写一个udp服务器,实现字母的大小写转换(附udp和tcp服务器的区别)
服务器端:udp_ser.c#include <stdlib.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include <errno.h>#include <ctype.h>#include <sys/socket.h>#include <arpa/inet.h>/*udp:用户数据报协议,是一种无连接的传输层协议,原创 2020-08-31 11:12:06 · 849 阅读 · 0 评论