多线程服务端编程
学习多线程编程,实现简易服务器
bigboss8264
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
libevent学习之Reactor模式
1.什么是Reactor模式维基百科上说:“The reactor design pattern is an event handling pattern for handling service requests delivered concurrently by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronously to as原创 2020-08-09 18:54:28 · 507 阅读 · 0 评论 -
Linux I/O模式
一、概念说明1. 用户空间与内核空间现在操作系统都是采用虚拟存储器,那么对32位操作系统而言,它的寻址空间(虚拟存储空间)为4G(2的32次方)。操作系统的核心是内核,独立于普通的应用程序,可以访问受保护的内存空间,也有访问底层硬件设备的所有权限。为了保证用户进程不能直接操作内核(kernel),保证内核的安全,操心系统将虚拟空间划分为两部分,一部分为内核空间,一部分为用户空间。针对linux操作系统而言,将最高的1G字节(从虚拟地址0xC0000000到0xFFFFFFFF),供内核使用,称为内核原创 2020-09-10 15:29:37 · 260 阅读 · 0 评论 -
select、poll、epoll简单比较
1. select模型int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);select 允许应用程序监视一组文件描述符,等待一个或者多个描述符成为就绪状态,从而完成 I/O 操作。 fd_set 使用数组实现,数组大小使用 FD_SETSIZE 定义,所以只能监听少于 FD_SETSIZE 数量的描述符。有三种类型的描述符类型:readset、writ原创 2020-09-10 14:19:27 · 368 阅读 · 0 评论 -
Linux网络编程基础API
1. socket地址API主机字节序和网络字节序字节序分为大端字节序(高字节存储在低地址处)和小端字节序(高位字节存储在内存的高地址处)。小端字节序又称主机字节序,大端字节序也称网络字节序。主机字节序和网络字节序转换函数:#include<netinet/in.h>unsigned long int htonl(unsigned long int hostlong);unsigned short int htons(unsigned short int hostlong原创 2020-08-22 16:46:39 · 227 阅读 · 0 评论 -
多线程编程
创建线程和结束线程基础API创建一个线程的函数 pthread_create#include<pthread.h>int pthread_create(pthread_t* thread, const pthread_attr_t* attr, void*(start_routine)(void*), void* arg);/* 参数:*1. thread参数是新线程的标识符,后续pthread_* 函数通过它引用新线程,pthread_t是一个整数类型。*2. attr原创 2020-08-19 10:23:57 · 159 阅读 · 0 评论
分享