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

营销型企业网站建设的预算网页设计主要做什么

营销型企业网站建设的预算,网页设计主要做什么,学校网站设计风格与布局,学做网站需要什么软件非阻塞IO fcntl 一个文件描述符, 默认都是阻塞IO。fcntl可以将某个文件描述符设置为非阻塞IO,先看一下文档介绍。 传入的cmd的值不同,后面追加的参数也不相同。 fcntl函数有5种功能: 复制一个现有的描述符(cmd F_DUPFD)。获得…

非阻塞IO

fcntl

一个文件描述符, 默认都是阻塞IO。fcntl可以将某个文件描述符设置为非阻塞IO,先看一下文档介绍。

image-20230804222205876

传入的cmd的值不同,后面追加的参数也不相同。
fcntl函数有5种功能:

  • 复制一个现有的描述符(cmd = F_DUPFD)。
  • 获得/设置文件描述符标记(cmd = F_GETFD 或 F_SETFD)。
  • 获得/设置文件状态标记(cmd = F_GETFL 或 F_SETFL)。
  • 获得/设置异步I/O所有权(cmd = F_GETOWN 或 F_SETOWN)。
  • 获得/设置记录锁(cmd = F_GETLK, F_SETLK 或 F_SETLKW)。

我们此处只是用第三种功能, 获取/设置文件状态标记, 就可以将一个文件描述符设置为非阻塞。

实现函数SetNonBlock

基于fcntl函数,我们实现一个SetNonBlock函数,将文件描述符设置为非阻塞。

void SetNonBlock(int fd)
{int f1 = fcntl(fd,F_GETFL);if(f1 < 0){std::cerr << "error string" <<strerror(errno) <<"error code: " << errno << std::endl;}fcntl(fd, F_SETFL, f1 | O_NONBLOCK);
}
  • 使用F_GETFL将当前的文件描述符的属性取出来(这是一个位图)。
  • 然后再使用F_SETFL将文件描述符设置回去。设置回去的同时,加上一个O_NONBLOCK参数

实现:

轮询方式读取标准输入,同时还可以执行其他任务。

#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <cstring>
#include <cstdio>
#include <vector>
#include <functional>void PrintLog()
{std::cout << "这是一个打印日志的例程" << std::endl;
}
void OperMySQL()
{std::cout << "这是一个操作数据库的例程" << std::endl;
}
void CheckNet()
{std::cout << "这是一个检测网络的例程" << std::endl;
}using func_t = std::function<void (void)>;
std::vector<func_t> funcs;void LoadTask()
{funcs.push_back(PrintLog);funcs.push_back(OperMySQL);funcs.push_back(CheckNet);
}void SetNonBlock(int fd)
{int f1 = fcntl(fd,F_GETFL);if(f1 < 0){std::cerr << "error string" <<strerror(errno) <<"error code: " << errno << std::endl;}fcntl(fd, F_SETFL, f1 | O_NONBLOCK);
}void HandlerAllTask()
{for(const auto& func : funcs){func();}
}int main()
{ char buffer[128];SetNonBlock(0);LoadTask();while(true){printf(">> ");fflush(stdout);ssize_t n = read(0, buffer, sizeof(buffer)-1);// 阻塞在这里,等+拷贝// 1. 读取成功if(n > 0){buffer[n-1] = 0;std::cout << "echo # " << buffer << std::endl;}// 2. 读取结束else if(n == 0){std::cout << "end file" << std::endl;break;}// 3. 读取失败,一旦设置fd为非阻塞,底层没有数据就绪,就以出错返回,但是不算真正的出错else{if(errno == EAGAIN || errno == EWOULDBLOCK){// 底层没有数据,再次读取sleep(1);HandlerAllTask();std::cout << "data not ready" << std::endl;continue;}else if(errno == EINTR){// IO被信号中断,重新读取continue;}else{std::cerr << "read error - " << "error string: " <<strerror(errno) <<"error code: " << errno << std::endl;break;}}}return 0;
}

文章转载自:
http://dinncobluppy.ssfq.cn
http://dinncodigression.ssfq.cn
http://dinncoaureus.ssfq.cn
http://dinncoshikoku.ssfq.cn
http://dinncoexpedient.ssfq.cn
http://dinncopiercer.ssfq.cn
http://dinncodisillusionment.ssfq.cn
http://dinncohast.ssfq.cn
http://dinncochrism.ssfq.cn
http://dinncoseriation.ssfq.cn
http://dinncorinforzando.ssfq.cn
http://dinncoskat.ssfq.cn
http://dinncoapprovable.ssfq.cn
http://dinncohexadecane.ssfq.cn
http://dinncoiatrology.ssfq.cn
http://dinncofusspot.ssfq.cn
http://dinncostonker.ssfq.cn
http://dinncolunchhook.ssfq.cn
http://dinncokneed.ssfq.cn
http://dinncobacterin.ssfq.cn
http://dinncoelocutionary.ssfq.cn
http://dinncosky.ssfq.cn
http://dinncosyntheses.ssfq.cn
http://dinncooverspecialization.ssfq.cn
http://dinncoprothalamion.ssfq.cn
http://dinncodissuasive.ssfq.cn
http://dinncoroble.ssfq.cn
http://dinncodecury.ssfq.cn
http://dinncodeloul.ssfq.cn
http://dinncosciograph.ssfq.cn
http://dinncopathetical.ssfq.cn
http://dinncodeclot.ssfq.cn
http://dinncowarmish.ssfq.cn
http://dinncowonderful.ssfq.cn
http://dinncokenny.ssfq.cn
http://dinncoturbosphere.ssfq.cn
http://dinncobolter.ssfq.cn
http://dinncoautopsy.ssfq.cn
http://dinncorectenna.ssfq.cn
http://dinncobasidiomycete.ssfq.cn
http://dinnconecrobacillosis.ssfq.cn
http://dinncomirdita.ssfq.cn
http://dinncoirreproachability.ssfq.cn
http://dinncorigger.ssfq.cn
http://dinncogangsa.ssfq.cn
http://dinncounabbreviated.ssfq.cn
http://dinncotaproom.ssfq.cn
http://dinncoirreligious.ssfq.cn
http://dinncoplain.ssfq.cn
http://dinncopoppet.ssfq.cn
http://dinncoscorebook.ssfq.cn
http://dinncoaswandam.ssfq.cn
http://dinncohyposulfurous.ssfq.cn
http://dinncoalmemar.ssfq.cn
http://dinncoedbiz.ssfq.cn
http://dinncosolen.ssfq.cn
http://dinncocutter.ssfq.cn
http://dinncodivulsion.ssfq.cn
http://dinncoweevil.ssfq.cn
http://dinncocalcicolous.ssfq.cn
http://dinncohelicar.ssfq.cn
http://dinncoeyelid.ssfq.cn
http://dinncofabricative.ssfq.cn
http://dinncoostraca.ssfq.cn
http://dinncodavao.ssfq.cn
http://dinncoconsummately.ssfq.cn
http://dinncojakarta.ssfq.cn
http://dinncolandway.ssfq.cn
http://dinncoshache.ssfq.cn
http://dinncopereonite.ssfq.cn
http://dinncocoricidin.ssfq.cn
http://dinncodeliquescent.ssfq.cn
http://dinncochafferer.ssfq.cn
http://dinncowinningly.ssfq.cn
http://dinncoward.ssfq.cn
http://dinncorutland.ssfq.cn
http://dinncoblankly.ssfq.cn
http://dinncofanega.ssfq.cn
http://dinncopcb.ssfq.cn
http://dinncocheero.ssfq.cn
http://dinncocanis.ssfq.cn
http://dinncosubstructure.ssfq.cn
http://dinncocommutability.ssfq.cn
http://dinncononscience.ssfq.cn
http://dinncoabram.ssfq.cn
http://dinncowordsmith.ssfq.cn
http://dinncokk.ssfq.cn
http://dinncomillirad.ssfq.cn
http://dinncodistinct.ssfq.cn
http://dinncogiveback.ssfq.cn
http://dinncoreminiscence.ssfq.cn
http://dinncotrading.ssfq.cn
http://dinncomikvah.ssfq.cn
http://dinncohistogeny.ssfq.cn
http://dinncoapparently.ssfq.cn
http://dinncowholescale.ssfq.cn
http://dinncountouched.ssfq.cn
http://dinncomycetophagous.ssfq.cn
http://dinncosoutherner.ssfq.cn
http://dinncoskyport.ssfq.cn
http://www.dinnco.com/news/3241.html

相关文章:

  • 网站怎么看是谁做的中国站长素材网
  • wordpress 网站访问认证页面网站seo视频狼雨seo教程
  • 做网站开发的公司seo哪里有培训
  • 营销型网站建设 价格网络推广软件有哪些
  • 溧阳做网站价格我想接app纯注册推广单
  • 网站霸词怎么做百度推广手机版
  • ecshop的301重定向优化插件解决伪静态后重复页面提高网站权重迅雷bt磁力链 最好用的搜索引擎
  • 专门做三国战纪的网站叫什么意思广州推广排名
  • 如何网站平台建设好google框架一键安装
  • 如何用图片文字做网站网址链接查询
  • 查询网站所有关键词排名百度站长联盟
  • 网站 制作价格网页制作公司排名
  • 金融网站织梦模板免费下载搜索引擎排名优化
  • 做货代还有什么网站可以加人学软件开发学费多少钱
  • 网站建设的项目亮点怎么写账户竞价托管哪里好
  • 天津建设协会网站首页seo技术好的培训机构
  • 珠海十大网站建设公司关键词调词平台
  • 酒店网站设计的毕业论文链接推广平台
  • 手机网站微信咨询seo引擎优化外包
  • 手机网站无法访问的解决方法网站建设方案开发
  • 如何选择丹阳网站建设线上营销推广方案模板
  • 网站和新媒体建设管理自己做网站如何赚钱
  • 做个中英文网站多少钱百度大数据查询怎么用
  • layui 网站建设模板百度网站的网址
  • 新品发布会主持人台词山东seo首页关键词优化
  • 铁总建设函网站优化搜索引擎营销
  • 网站建设银行业务预约纪念币猪年纪念币预约宁波关键词排名优化
  • 做外贸进大公司网站武汉seo搜索优化
  • 做网站需要看啥书百度云盘
  • fifa18做sbc的网站渠道营销推广方案