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

个人做网站需要学什么只是中国电子商务官网首页

个人做网站需要学什么只是,中国电子商务官网首页,桂平网站设计,西安建设工程信息网是谁开发的自带buffer的事件-bufferevent bufferevent实际上也是一个event#xff0c;只不过比普通的event高级#xff0c;他的内部有两个缓冲区#xff0c;以及一个文件描述符#xff08;网络套接字#xff09;。一个网络套接字有读写两个缓冲区#xff0c;bufferevent同样也带有…自带buffer的事件-bufferevent bufferevent实际上也是一个event只不过比普通的event高级他的内部有两个缓冲区以及一个文件描述符网络套接字。一个网络套接字有读写两个缓冲区bufferevent同样也带有两个缓冲区。所以有四个缓冲区。 bufferevent的读事件回调触发时机 当数据由内核的读缓冲区到bufferevent的读缓存区时会触发bufferevent的读事件回调需要注意的是数据由内核到bufferevent的过程不是用户程序执行的而是bufferevent内部操作的。 bufferevent的写事件回调函数触发时机 当用户程序将数据写到bufferevent的写缓冲区之后bufferevent会自动触发写事件回调函数。需要注意的是数据由bufferevent到内核的过程不是用户程序执行的而是bufferevent内部操作的。  事件回调 当bufferevent绑定的socket连接断开或者异常的时候触发事件回调。 bufferevent常用的API函数 struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options);  函数说明*bufferevent_socket_new对已经存在的socket创建bufferevent事件 options: BEV_OPT_CLOSE_ON_FREE --释放bufferevent自动关闭底层接口当bufferevent被释放之后文件描述符也被close; BEV_OPT_THREADSAFE--使bufferevent能够在多线程下是安全的 /**   Create a new socket bufferevent over an existing socket.   param base the event base to associate with the new bufferevent.   param fd the file descriptor from which data is read and written to.         This file descriptor is not allowed to be a pipe(2).         It is safe to set the fd to -1, so long as you later         set it with bufferevent_setfd or bufferevent_socket_connect().   param options Zero or more BEV_OPT_* flags   return a pointer to a newly allocated bufferevent struct, or NULL if an       error occurred   see bufferevent_free()   */ int bufferevent_socket_connect(struct bufferevent *, struct sockaddr *, int); 函数说明调用此函数可以将bufferevent事件于通信的socket进行绑定。 /**    Launch a connect() attempt with a socket-based bufferevent.    When the connect succeeds, the eventcb will be invoked with    BEV_EVENT_CONNECTED set.    If the bufferevent does not already have a socket set, we allocate a new    socket here and make it nonblocking before we begin.    If no address is provided, we assume that the socket is already connecting,    and configure the bufferevent so that a BEV_EVENT_CONNECTED event will be    yielded when it is done connecting.    param bufev an existing bufferevent allocated with        bufferevent_socket_new().    param addr the address we should connect to    param socklen The length of the address    return 0 on success, -1 on failure.  */   调用此函数后通信的socket于bufferevent缓冲区进行绑定后面调用了bufferevent_setcb函数以后会对bufferevent缓冲区的读写操作的事件设置回调函数。 void bufferevent_free(struct bufferevent *bufev); /**   Deallocate the storage associated with a bufferevent structure.   param bufev the bufferevent structure to be freed.   */   void bufferevent_setcb(struct bufferevent *bufev,     bufferevent_data_cb readcb, bufferevent_data_cb writecb,     bufferevent_event_cb eventcb, void *cbarg); /**   Changes the callbacks for a bufferevent.   param bufev the bufferevent object for which to change callbacks   param readcb callback to invoke when there is data to be read, or NULL if      no callback is desired   param writecb callback to invoke when the file descriptor is ready for      writing, or NULL if no callback is desired   param eventcb callback to invoke when there is an event on the file      descriptor   param cbarg an argument that will be supplied to each of the callbacks      (readcb, writecb, and errorcb)   see bufferevent_new()   */   回调函数原型 typedef void (*bufferevent_data_cb)(struct bufferevent *bev, void *ctx);  typedef void (*bufferevent_event_cb)(struct bufferevent *bev, short what, void *ctx); int bufferevent_write(struct bufferevent *bufev,     const void *data, size_t size); /**   Write data to a bufferevent buffer.   The bufferevent_write() function can be used to write data to the file   descriptor.  The data is appended to the output buffer and written to the   descriptor automatically as it becomes available for writing.   param bufev the bufferevent to be written to   param data a pointer to the data to be written   param size the length of the data, in bytes   return 0 if successful, or -1 if an error occurred   see bufferevent_write_buffer()   */ size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size);  /**   Read data from a bufferevent buffer.   The bufferevent_read() function is used to read data from the input buffer.   param bufev the bufferevent to be read from   param data pointer to a buffer that will store the data   param size the size of the data buffer, in bytes   return the amount of data read, in bytes.  */
http://www.zqtcl.cn/news/74654/

相关文章:

  • 太原网站优化网站如何能让百度收录
  • 佛山seo网站网站续费合同
  • 专业的餐饮网站建设提供营销网站建设公司
  • 廊坊市建设局网站如何建立一个网站平台网站
  • wordpress 搬家 域名seo排名方案
  • 佛山高明网站建设设计做仿网站的书
  • 网站建设5个why快速seo排名优化
  • 网上书城网站开发百度装修网站
  • 微信公众号授权给网站网站的设计方案在哪里
  • 网站建设课程设计实验报告开封seo推广
  • 设计师培训 网站电子商务主要课程
  • 公司网站内容相近网站主流系统
  • 网站的劣势自己做的网站出现左右滑动条
  • 海口 做网站品牌推广与传播方案
  • 提供哈尔滨网站建设服务怎样建设免费网站
  • 高端品牌有哪些牌子优化教程网下载
  • 佛山哪有网站建设公司wordpress category.php
  • 有帮忙做儿童房设计的网站吗太原企业网站制作
  • 做外贸的怎么建立自己的网站网站策划方案范文
  • 做英文行程的网站欧洲网站设计
  • 公司网站费用石家庄推广网站
  • 自响应式网站建设清单建设网站需要想好的问题
  • 橙色网站欣赏wordpress 模板代码
  • 网站首页轮播图片素材wordpress主题 百度云
  • 长春老火车站图片贵阳金阳网站建设公司
  • 民企厂房建设招标网站兰州网站建设最新招聘信息
  • 网站怎么进百度关键词排名批量查询工具
  • 网站的结构设计百度搜一搜
  • vps网站如何绑定多个域名微商城小程序商城
  • 哈尔滨网站建设口碑好全广告网站