libevent使用总结

梦竹 2014-07-03 09:53:17
Hi,亲们,又到了讨论技术问题的时间了!!


在这里我们讨论下关于libevent的使用总结,想总结一些使用细节上的问题,因为框架都看懂了,但是离具体操作还有一段距离,要更好滴越过这道鸿沟就需要总结细节。


提几点希望:
1.喷子们请高抬贵手放过此贴
2.尽量不要只是为了留下足迹,当然留下了也无所谓啦


libevent使用总结:
1.与客户端建立连接的时候,每个客户端都需要有自己的事件,比如客户端1需要读和写,就需要有自己的读事件1和写事件1,;客户端2要读和写,就需要有自己的读事件2和写事件2,并且这些事件都需要被注册到eventbase上。
2.libevent是对epoll,poll,select等的封装,依据不同的平台会自动选择使用哪一种方式,而不是对其做变种。
3.event_base_loopbreak()和event_base_loopexit()函数好像都需要事件触发才可以生效。
...全文
2028 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Marcelxx 2017-02-28
  • 打赏
  • 举报
回复
能不能给个udp的例子啊
fly2010love 2015-06-01
  • 打赏
  • 举报
回复
可以看看memcache的源码,我们目前项目就是参考memcache使用libevent的方式架构来设计的,性能确实很好,而且几个月的并发测试也很稳定
chouer0738 2014-09-15
  • 打赏
  • 举报
回复
精辟,不错。。。。。。。。
梦竹 2014-09-10
  • 打赏
  • 举报
回复
引用 7 楼 oChuangZaoWeiLai12 的回复:
这个东西到底有什么用啊?
很有用
super超 2014-07-30
  • 打赏
  • 举报
回复
这个东西到底有什么用啊?
FeelTouch Labs 2014-07-23
  • 打赏
  • 举报
回复
(1)事件驱动(event-driven),高性能; (2)轻量级,专注于网络,不如 ACE 那么臃肿庞大; (3)源代码相当精炼、易读; (4)跨平台,支持 Windows、Linux、*BSD和 Mac Os; (5)支持多种 I/O多路复用技术, epoll、poll、dev/poll、select 和kqueue 等; (6)支持 I/O,定时器和信号等事件; (7)注册事件优先级;
laowang2 2014-07-23
  • 打赏
  • 举报
回复
梦竹 2014-07-22
  • 打赏
  • 举报
回复
突然想了解下服务器程序开发
  • 打赏
  • 举报
回复
nginx: libevent with non_block, one worker process (by default) v.s. apache multi-processing or multi-threading model
  • 打赏
  • 举报
回复
IMHO, libevent is not the real "asynchronous i/o" defined in APUE. The author misled users to believe they are in asynchronous i/o mode but what happens is that the synchronous form is hidden inside libevent and this gives users the illusion that my program goes asynchronous, see I didn't have any synchronization at all in my codes... http://www.wangafu.net/~nickm/libevent-book/01_intro.html "But we’re still not done. Because generating and reading the select() bit arrays takes time proportional to the largest fd that you provided for select(), the select() call scales terribly when the number of sockets is high. [2] Different operating systems have provided different replacement functions for select. These include poll(), epoll(), kqueue(), evports, and /dev/poll. All of these give better performance than select(), and all but poll() give O(1) performance for adding a socket, removing a socket, and for noticing that a socket is ready for IO. Unfortunately, none of the efficient interfaces is a ubiquitous standard. Linux has epoll(), the BSDs (including Darwin) have kqueue(), Solaris has evports and /dev/poll… and none of these operating systems has any of the others. So if you want to write a portable high-performance asynchronous application, you’ll need an abstraction that wraps all of these interfaces, and provides whichever one of them is the most efficient. And that’s what the lowest level of the Libevent API does for you. It provides a consistent interface to various select() replacements, using the most efficient version available on the computer where it’s running."
梦竹 2014-07-09
  • 打赏
  • 举报
回复
这个有点爆冷门

1,092

社区成员

发帖
与我相关
我的任务
社区描述
云计算服务器、网络、虚拟化相关讨论
社区管理员
  • 服务器
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧