break; 5、异步发送数据 :lws_callback_on_writable不支持多线程,可以使用lws_cancel_service 退出lws_service,然后判断是否有数据发送:(lws_service 中的timeout参数已经没用了,见下文注释) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 intCWssClientHelper::S...
libwebsocket_callback_on_writable calls lws_change_pollfd(wsi, 0, LWS_POLLOUT). This sets fd.events of my file descriptor to POLLOUT and calls libwebsocket_cancel_service. I can verify this by printing out the fd.events value at the end of the function. It shows 5. Which is (POLLIN...
自己项目所需利用c++实现了http、websocket服务,用于浏览器和本地应用程序通信,我是在VS2017环境下编写的,其中使用的c++的json库jsoncpp,c++的常见算法库cryptopp和二维码生成库qrencode,二维码库读者可以直接移除就可以了,这是我项目后面要用到的,我只是添加进去了。
git clone https://github.com/ithewei/libhv.gitcdlibhv ./configure make bin/httpd -h bin/httpd -d#bin/httpd -c etc/httpd.conf -s restart -dps aux|grep httpd#http file servicebin/curl -v localhost:8080#http indexof servicebin/curl -v localhost:8080/downloads/#http api servicebin/curl...