Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

canonical libwebsockets.org networking library

License

NotificationsYou must be signed in to change notification settings

warmcat/libwebsockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI statusCoverity Scan Build StatusCII Best Practices

Libwebsockets

** v4.4 is released, you can follow it on v4.4-stable **

Libwebsockets is a simple-to-use, MIT-license, pure C library providing client and serverforhttp/1,http/2,websockets,MQTT and other protocols in a security-minded,lightweight, configurable, scalable and flexible way. It's easy to build andcross-build via cmake and is suitable for tasks from embedded RTOS through masscloud serving.

It supports a lot of lightweight ancilliary implementations for things like JSON,CBOR, JOSE, COSE, and supports OpenSSL and MbedTLS v2 and v3 out of the box for everything.It's very gregarious when it comes to event loop sharing, supporting libuv, libevent, libev,sdevent, glib and uloop, as well as custom event libs.

100+ independent minimal examples for various scenarios, CC0-licensed(public domain) for cut-and-paste, allow you to get started quickly.

There are a lot of READMEs on a variety of topics.

We do a huge amount of CI testing per push, currently 582 builds on 30 platforms.You can see the lws CI rack and read about how lws-based Sai is used to coordinate all the testing.

overview

News

HTML + CSS + JPEG + PNG display stack in lws

Want to drive your EPD or TFT / OLED display using HTML + CSS? Only got an ESP32?

Want remote JPEGs, PNGs, HTML, RGBA composition, gamma, error diffusion if needed?

Realtime render into a line buffer because you don't have enough heap for a framebuffer?

Take a look here...

Perl binding for lws available

Thanks to Felipe Gasper, there's now aperl binding for lws available at metacpan,this uses the recent generic event loop support in lws to have lws as a guest on an existing perl event loop.

Lws examples switching to Secure Streams

Secure Streams direct

Secure Streams support in lws was introduced a couple of years ago, it's ahigher-level interface to lwswsi-level apis that simplifies connectivity bysegregating connection policy like protocol and endpoint information into aseparateJSON policy file, and just having thecode deal with payloads; as manydetails of the wire protocol as possible are hidden or moved to the policy, souser code is almost identical even if the wire protocol changes.

The user code just asks to create a SS by "streamtype name", it is createdaccording to the details (protocol, endpoint, etc) under the same name in thepolicy.

Key policy entries like endpoint can contain${metadata-name} stringsubstitutions to handle runtime adaptations via metadata. h1, h2, ws and mqttare supported.

As a layer on top of thewsi apis, SS provides a higher-level way to accessthe existing wsi-level capabilities, both kinds of API will remain supported.Secure Streams are longer-lived than a single wsi, so an SS can coordinateretries by itself. SS-based user code is typically significantly smaller andmore maintainable than wsi layer.

In main branch I have moved the older examples into./minimal-examples-lowleveland am starting to port more cases from there into SS-based examples.

Comparison between wsi and SS level lws usage

Feature"low-level" wsi waySecure Streams way
Create contextcodesame
Loop support, sul schedulerdefault, event libssame
Supports comms modeClient, Server, Rawsame
Supports protocolsh1, h2, ws, mqtt (client)same
TLS supportmbedtls (including v3), openssl (including v3), wolfssl, boringssl, aws-lc, libresslsame
Serializable, proxiable, muxable, transportableNoYes
Auto-allocated per-connection user objectpss specified in lws_protocolsSpecified in ss info struct
Connection User APIProtocol-specific lws_protocols cbs (> 100)SS API (rx, tx, state callbacks only)
Sending adaptationlws_callback_on_writeable() + WRITEABLElws_ss_request_write() + tx() cb
Sending bufferUser-chosen + malloc'd partial handlingSS-provided, no partials
Create vhostscodeJSON policy
TLS validationcert bundle or codeJSON policy, or cert bundle
Connection retry / backoffcodeJSON policy, Auto
Nailing upcodeJSON policy, Auto
Endpoint and protocol detailsspread around the codeJSON policy
Protocol selection, pipeline / stream sharingcodeJSON policy
ws subprotocol selectioncodeJSON policy
ws binary / textcodeJSON policy
Protocol-specific metadataProtocol-specific apis in code (eg, lws_hdr)JSON policy, generic metadata apis in code
Connection validity rulesstructJSON policy, Auto
Stream as Long PollcodeJSON policy
AuthcodeJSON policy + automatic rotation if provider supported, else code

Serialized Secure Streams

Secure Streams direct

Secure Streams APIs are alsoserializable, the exact same client code canfulfil the connection directly in the same process as you would expect, orforward the actions, metadata and payloads to anSS Proxy that owns the policyover a Unix Domain or TCP socket connection to be fulfilled centrally. Thisallows, eg, h2 streams from different processes sharing a single connection.

Secure Streams direct

The serialized SS can also travel over generic transports like UART, anexampleis provided implementing the Binance example on an RPi Pico with a UART transportto aUART transport SS proxy, where the pico itself has no network stack, tls, compression orwss stack, but can send and receive to and from the endpoint as if it did.

The optionallws_trasport_mux is used to interpose between the UART transportand the SSPC layer, allowing a single pipe to carry many separate SS connections.

The user SS code is identical however it is transported, muxed and fulfilled.

v4.3 is released

See thechangelog

Support

This is the libwebsockets C library for lightweight websocket clients andservers. For support, visit

https://libwebsockets.org

You can get the latest version of the library from git:

Doxygen API docs for development:https://libwebsockets.org/lws-api-doc-main/html/index.html


[8]ページ先頭

©2009-2025 Movatter.jp