AtlatestRepositorysigil-websocket
sigil-websocket / treeREADME.md
1
# sigil-websocket3
A [Sigil](https://codeberg.org/sigil/sigil) library for WebSocket client connections (RFC 6455). Supports both `ws://` and `wss://` (TLS) with cooperative non-blocking I/O.5
## Features7
- **TLS support** -- connect to `ws://` and `wss://` endpoints8
- **Frame encoding/decoding** -- text, binary, ping, pong, close9
- **Client masking** -- automatic frame masking per RFC 645510
- **Fragmentation** -- transparent message reconstruction from continuation frames11
- **Cooperative I/O** -- non-blocking receive that yields to the scheduler13
## Usage15
Add `sigil-websocket` as a dependency in your `package.sgl`:17
```scheme18
(from-git url: "codeberg:sigil/sigil-websocket" package: "sigil-websocket")19
```21
Then connect and exchange messages:23
```scheme24
(import (sigil websocket))26
(define ws (ws-connect "wss://echo.websocket.org"))28
(ws-send ws "Hello, WebSocket!")30
(let loop ()31
(let ((msg (ws-receive ws)))32
(when (string? msg)33
(display msg)34
(loop))))36
(ws-close ws)37
```39
## Modules41
| Module | Description |42
|--------|-------------|43
| `(sigil websocket)` | Top-level re-exports |44
| `(sigil websocket frame)` | Frame encoding, decoding, masking |45
| `(sigil websocket connection)` | Handshake, send, receive, close |47
## Dependencies49
- sigil-stdlib50
- sigil-socket51
- sigil-crypto53
## Building55
```bash56
sigil deps install57
sigil build58
sigil test59
```61
## License63
BSD-3-Clause