caosiyang / websocket Goto Github PK
View Code? Open in Web Editor NEWWebSocket server demo implemented with C++ & libevent
WebSocket server demo implemented with C++ & libevent
connection.cpp
send_a_frame function
the function of bufferevent_write return value is 0 or -1
fb->len is the real data length
so the return value always is -1
哈喽, 我想问一下, 在websocket握手的时候,禁用调用libevent 的EV_READ选项, 如果这个时候客户端断掉连接, 应该不能及时的关闭掉连接, 并且 bufferevent_write向一个关闭的fd去写,也是不会触发异常的,这样连接对应的bufferevent是不是就释放不掉了呢?
Here is a valgrind snippet
==10036== 3,824 (1,072 direct, 2,752 indirect) bytes in 2 blocks are definitely lost in loss record 16 of 16
==10036== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10036== by 0x4E52DA0: bufferevent_socket_new (bufferevent_sock.c:354)
==10036== by 0x4020C1: listencb(evconnlistener*, int, sockaddr*, int, void*) (demo.cpp:41)
==10036== by 0x4E6082E: listener_read_cb (listener.c:418)
==10036== by 0x4E58538: event_persist_closure (event.c:1580)
==10036== by 0x4E58538: event_process_active_single_queue (event.c:1639)
==10036== by 0x4E58DEE: event_process_active (event.c:1738)
==10036== by 0x4E58DEE: event_base_loop (event.c:1961)
==10036== by 0x4022A6: main (demo.cpp:78)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.