當前位置:
首頁 >
【WebRTC---进阶篇】(二)libevent实现高性能网络服务器
發布時間:2023/12/3
53
豆豆
生活随笔
收集整理的這篇文章主要介紹了
【WebRTC---进阶篇】(二)libevent实现高性能网络服务器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
libevent編譯與安裝
libevent官網
Linux平臺安裝編譯libevent
wget -c addr --no-check-certificate ./configure --prefix=/usr/local/libevent make -j 8 make install #include <event2/listener.h> #include <event2/bufferevent.h> #include <event2/buffer.h> #include <event2/thread.h>#include <arpa/inet.h>#include <string.h> #include <stdlib.h> #include <stdio.h> #include <errno.h>static void echo_read_cb(struct bufferevent *bev, void *ctx) {/* 獲取bufferevent中的讀和寫的指針 *//* This callback is invoked when there is data to read on bev. */struct evbuffer *input = bufferevent_get_input(bev);struct evbuffer *output = bufferevent_get_output(bev);/* 把讀入的數據全部復制到寫內存中 *//* Copy all the data from the input buffer to the output buffer. */evbuffer_add_buffer(output, input); }static總結
以上是生活随笔為你收集整理的【WebRTC---进阶篇】(二)libevent实现高性能网络服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【WebRTC---进阶篇】(一)服务器
- 下一篇: 【WebRTC---进阶篇】(三)各流媒