TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Libwebsockets: pure C library for http, websockets, MQTT

171 点作者 seansh超过 1 年前

12 条评论

macgyverismo超过 1 年前
I started using this library last week. It was easy to get started and running. When I wanted to do stuff beyond the provided example I found nothing worked as I had expected. For example, you supply a user pointer when you create a lws_context. There is a user pointer argument in the callback where you do all the actual work. One would expect these to be the Same, but they are not. Instead you have to use two different calls to get from your current connection to the user pointer which is set for all connections. Did it work? Yes. But it was very suprising behavior. Another problem I ran into was getting the event loop to be non-blocking for use in a coroutine. Appearently I was expected to use one of the preselected event libraries, which I was not. I was expected to implement a dozen or so callbacks for which there was little or no helpfull documentation. Eventually I found that there was a hack where I could pass -1 to the timeout parameter. Now the service call was non blocking. It would have been fine if the call had blocked for a millisecond or so, but that did not work. So the time-out parameter was either -1 or any other value. I kept bumping into suprises like this. The library solved a problem for me, so I will continue to use it. Unfortunately I cant recommend it to anyone unless you are willing and able to spend a good portion of your time getting this beast tamed.
评论 #38900154 未加载
评论 #38900690 未加载
renewiltord超过 1 年前
Has anyone bridged this to Java with JNI and used it well for a HTTP&#x2F;2 client? Considering doing this some time within the next month but if someone already has done work would be useful to see.<p>Response to below user since rate limited:<p>Few Java libraries support everything required. At the socket level if you want to get cmsg struct information you’re not going to get that from most Java libraries and you need that configurable since sometimes you use SO_TIMESTAMP et al. and other times you don’t and if you use SW for that you can lose a few hundred micros there.<p>OTOH libwebsockets very easy to modify. Downside is it manages the loop. So you need to do some engineering. But if someone has already learned the lessons there it would be helpful to me. If they haven’t, I’ll just do it I suppose.
评论 #38897020 未加载
seansh超过 1 年前
Main website: <a href="https:&#x2F;&#x2F;libwebsockets.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;libwebsockets.org&#x2F;</a>
VikingCoder超过 1 年前
When I have a chance, I want to compile this with Cosmopolitan Libc!
评论 #38898596 未加载
WanderPanda超过 1 年前
Damn I just yesterday was pulling my hair out to get boost::beast to run (how unergonomic can an api be?!). Now I‘m considering to switch but what I really need is long term stability. I‘d rather like to not ever touch this code again, but it should compile over the next 5-10 years. I‘m not sure which one would be preferable in that regard
评论 #38899154 未加载
qwertox超过 1 年前
This is what the Mosquitto MQTT broker is using to offer Websocket support.<p>Interesting to see that this has a MQTT client integrated.
ricardo81超过 1 年前
I&#x27;ve used this at point in the past and it did seem relatively pain free to implement. Never quite got round to how certs could be reloaded though, while still honouring requests.
matt3210超过 1 年前
Love this library. Maintainer answers GitHub issues too!
muragekibicho超过 1 年前
Amazing library! Super simple and well maintained
评论 #38897143 未加载
9659超过 1 年前
steal the example programs, and make them your own.<p>good performance, good reliability.
adamzegelin超过 1 年前
HTTP, websockets, MQTT, ... plus the kitchen sink it seems:<p><pre><code> - JSON parsing - DNS, DHCP and NTP clients - SOCKS5 proxy support - DBUS client and server - Threadpools - SSH - JPEG and PNG decoding - HTML and CSS parsing - DOM layout and rendering to a frame buffer - OTA update client - GPIO, i2c, PWM, SPI - SSH server - ACME client - ...</code></pre>
评论 #38897493 未加载
评论 #38897533 未加载
omeid2超过 1 年前
Genuine question. With Rust and C++, even for embedded systems, what is the use case for starting a new project that does binary encoding and network with such an unsafe language like C?<p>I find it almost inexcusable at this point.
评论 #38899015 未加载
评论 #38898874 未加载
评论 #38899079 未加载
评论 #38898731 未加载
评论 #38898727 未加载
评论 #38899377 未加载