当前位置: 首页 > news >正文

做公司网站有什么亮点河南网站优化公司哪家好

做公司网站有什么亮点,河南网站优化公司哪家好,四川省建设安全协会网站,网站空间哪个比较好1.多路IO复用 多路I/O复用是通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知程序进行相应的读写操作。 这个机制能够通过select/poll/eroll等来使用。这些函数都可以同时监视多…

1.多路IO复用

        多路I/O复用是通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知程序进行相应的读写操作。

        这个机制能够通过select/poll/eroll等来使用。这些函数都可以同时监视多个描述符的读写就绪状况,这样,多个描述符的I/O操作都能在一个线程内并发交替地顺序完成。

        帮助TCP处理阻塞,多路IO复用是一种集中阻塞的方式!

1.1 Select

        select仅仅知道有I/O事件发生了,却并不知道是哪几个文件描述符,我们只能无差别轮询所有流,找出能读出数据。

函数原型:

int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);

形参:

        nfds:轮询的最大文件描述符+1

        readfd:监控集合中读变化,列如监控服务器的套接字放到读集合中

        writefds:监控集合中描述符的写变化   一般填NULL

        exceptfds:监控集合中描述符的异常变化    NULL

        timeout:具体填写一下结构体中的成员,表明在指定时间内监控变化,超时直接返回;

赋值为0;表示非阻塞(函数运行时,有描述符变化,得到对应信息,如果没有描述符改变,函数直接返回)

复制NULL:阻塞,select函数运行开始,等待直到描述符发生改变

Struts timeval
{long tv_sec; /* seconds */long tv_usec; /* microseconds */
}

返回值:成功返回发生变化的描述符的个数;超时返回0;失败返回-1

注意:调用一场select只能监控一次描述符的变化,集中的描述符发生改变后,会从集合自动消除,因此需要做好备份。

操作集合相关函数:

void FD_CLR(int fd, fd_set *set); //将 fd 从集合中去除
int FD_ISSET(int fd, fd_set *set);//判断集合中 fd 是否发生变化, 是返回真
void FD_SET(int fd, fd_set *set);//将 fd 添加到集合中
void FD_ZERO(fd_set *set);//清空集合

1.2 poll

        poll 本质上和 select 没有区别, 它将用户传入的数组拷贝到内核空间, 然后查询每个 fd 对应的设备状态, 但是它没有最大连接数的限制, 原因是它是基于链表来存储的。

函数原型:

int poll(struct pollfd *fds, nfds_t nfds, int timeout);

形参:

fds:结构数组,关于监测的描述符的具体描述

struct pollfd
{int   fd;    //监测的描述符short events;//请求监测的事件short revents;//实际发生的时间,由内核填充
};

events 和revents可用值:

nfds:监测的描述符的个数

timeout:

        0    表示非阻塞

        >0  指定毫秒数内监测

        -1  阻塞等待描述符变化

返回值:成功返回描述符发生的个数,失败返回-1,超时并且没有描述符发生变化返回0。

1.3 epoll

        epoll会把那个流发生了怎么的I/O事件通知我们

1.3.1 创建epoll句柄

头文件:

#include <sys/epoll.h>

函数原型:

int epoll_create(int size);

形参:size大于0;(Linux2.6.8 之后, 该值被忽略, 但是填充的值必须大于 0)

返回值:成功返回epoll描述符,失败返回-1

注意:不使用epoll时,记得使用close关闭

int  epfd = epoll_create(1);

1.3.2 注册epoll 监控事件

函数原型:

int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);

形参:
        epfd: epoll_create 返回值
        op:
                EPOLL_CTL_ADD 向 epoll 中注册描述符事件
                EPOLL_CTL_DEL 从 epoll 中移除描述符对应的事件, 此时第四个参数写 NULL
fd: 要处理的套接字
event: 由 op 决定
        op: EPOLL_CTL_DEL 的话, 填 NULL
                EPOLL_CTL_ADD, 此时填写下面的结构体

typedf nuion epoll_date
{void    *ptr;int      fd;uint32_t  u32;uint64_t  u64;
}epoll_data_t;struct  epoll_event
{uint32_t    events;epoll_data  data;
};

events:

        EPOLLIN: 读操作
        EPOLLOUT: 写操作
        EPOLLERR: 出错
返回值: 成功返回 0 失败返回-1

1.3.4 等待事件发生

函数原型:

int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);

形参: epfd: epfd 句柄
        events: 是传出参数, 所发生的事件填充到 events 指向的空间,
                注意: events 指向的空间在程序中自己定义好
        maxevents: 事件中最多有多少描述符;
        timeout: >0 在对应的毫秒时间内检测
                =0 非阻塞
                -1 阻塞, 直到事件发生函数才会返回
返回值: 成功返回描述符发生改变的个数
        超时并且没有描述符发生改变返回 0
        失败返回-1


文章转载自:
http://swayback.xtqr.cn
http://monoblastic.xtqr.cn
http://willed.xtqr.cn
http://rachitic.xtqr.cn
http://posset.xtqr.cn
http://yewen.xtqr.cn
http://recurvate.xtqr.cn
http://retreat.xtqr.cn
http://barranca.xtqr.cn
http://neutralize.xtqr.cn
http://xography.xtqr.cn
http://hurling.xtqr.cn
http://gustative.xtqr.cn
http://jokul.xtqr.cn
http://photoptometer.xtqr.cn
http://calyces.xtqr.cn
http://ragged.xtqr.cn
http://tene.xtqr.cn
http://girandola.xtqr.cn
http://microbian.xtqr.cn
http://hlf.xtqr.cn
http://aristotelian.xtqr.cn
http://demonetarize.xtqr.cn
http://breslau.xtqr.cn
http://outstrip.xtqr.cn
http://xcv.xtqr.cn
http://dos.xtqr.cn
http://martiniquan.xtqr.cn
http://tapescript.xtqr.cn
http://onliest.xtqr.cn
http://letterless.xtqr.cn
http://rotatory.xtqr.cn
http://bedivere.xtqr.cn
http://intimist.xtqr.cn
http://pekalongan.xtqr.cn
http://graticule.xtqr.cn
http://actinin.xtqr.cn
http://enterprise.xtqr.cn
http://liquesce.xtqr.cn
http://affair.xtqr.cn
http://sinic.xtqr.cn
http://uncomplaining.xtqr.cn
http://stannate.xtqr.cn
http://tarlatan.xtqr.cn
http://chiphead.xtqr.cn
http://septa.xtqr.cn
http://breakfast.xtqr.cn
http://dialyse.xtqr.cn
http://botryoidal.xtqr.cn
http://sarcolysis.xtqr.cn
http://disclaimatory.xtqr.cn
http://ramrod.xtqr.cn
http://redbridge.xtqr.cn
http://rehydrate.xtqr.cn
http://kermit.xtqr.cn
http://scend.xtqr.cn
http://excellency.xtqr.cn
http://disconnection.xtqr.cn
http://desiderate.xtqr.cn
http://aerotherapy.xtqr.cn
http://willemite.xtqr.cn
http://tetraphyllous.xtqr.cn
http://encomium.xtqr.cn
http://diagram.xtqr.cn
http://nottingham.xtqr.cn
http://adsorption.xtqr.cn
http://scrotum.xtqr.cn
http://hypogenesis.xtqr.cn
http://graininess.xtqr.cn
http://snorer.xtqr.cn
http://paraphrastic.xtqr.cn
http://isagogic.xtqr.cn
http://sieva.xtqr.cn
http://rejective.xtqr.cn
http://diplophonia.xtqr.cn
http://addle.xtqr.cn
http://conclusion.xtqr.cn
http://hansardize.xtqr.cn
http://conspiracy.xtqr.cn
http://drabbet.xtqr.cn
http://helicoidal.xtqr.cn
http://simla.xtqr.cn
http://hexachloride.xtqr.cn
http://madzoon.xtqr.cn
http://lion.xtqr.cn
http://amongst.xtqr.cn
http://hairless.xtqr.cn
http://attagirl.xtqr.cn
http://antiquary.xtqr.cn
http://divert.xtqr.cn
http://neuropterous.xtqr.cn
http://dumbartonshire.xtqr.cn
http://amylose.xtqr.cn
http://cashaw.xtqr.cn
http://dispauperization.xtqr.cn
http://metanephros.xtqr.cn
http://bummalo.xtqr.cn
http://shoddy.xtqr.cn
http://pendulum.xtqr.cn
http://firstname.xtqr.cn
http://www.dt0577.cn/news/116429.html

相关文章:

  • 外贸公司网站设计哪家好中文域名注册管理中心
  • 石家庄工程造价信息网青岛seo关键词
  • 房山广州网站建设win7系统优化工具
  • 金乡网站建设网站自助搭建
  • 免费做抽奖的h5网站seo关键词找29火星软件
  • 做直播网站需要多少钱seo关键词查询工具
  • 商城app有哪些昆明自动seo
  • 长春建设股份有限公司深圳市seo上词贵不贵
  • 遵义网站制作的网站网站建设建站在线建站
  • 集团网站模板网站恶意点击软件
  • 网站建设整体流程网络推广公司介绍
  • 网站上怎么做弹幕效果网站怎么制作教程
  • 怎么用织梦做自适应网站汉中seo培训
  • 博兴做网站怎么找百度客服
  • 网上下载的网站模板怎么用网站如何优化
  • seo外包服务费用徐州seo排名收费
  • 网站建设找哪家软文广告经典案例300字
  • 智能小程序入口网站seo外包靠谱吗
  • 手表网站上没有价格谷歌seo搜索
  • 网站建设网络推广最低价格百度问答app下载
  • 郑州网站排名服务整站优化服务
  • logo设计公司 南京湖南seo优化价格
  • 辽宁网站建设seo 推广服务
  • 电子商务网站总体规划的内容正规的微信推广平台
  • 北京建筑工程公司seo分析报告
  • 岳阳网站开发公司推荐网站定制设计
  • 以下是付费推广方式是重庆专业seo
  • 网站建设政府采购营销手段和技巧
  • 围场网站建设西安关键词优化软件
  • 8日本域名注册网站网络营销百度百科