AtlatestRenderedmarkdown
Readme

sigil-websocket

A Sigil library for WebSocket client connections (RFC 6455). Supports both ws:// and wss:// (TLS) with cooperative non-blocking I/O.

Features

  • TLS support -- connect to ws:// and wss:// endpoints
  • Frame encoding/decoding -- text, binary, ping, pong, close
  • Client masking -- automatic frame masking per RFC 6455
  • Fragmentation -- transparent message reconstruction from continuation frames
  • Cooperative I/O -- non-blocking receive that yields to the scheduler

Usage

Add sigil-websocket as a dependency in your package.sgl:

(from-git url: "codeberg:sigil/sigil-websocket" package: "sigil-websocket")

Then connect and exchange messages:

(import (sigil websocket))

(define ws (ws-connect "wss://echo.websocket.org"))

(ws-send ws "Hello, WebSocket!")

(let loop ()
  (let ((msg (ws-receive ws)))
    (when (string? msg)
      (display msg)
      (loop))))

(ws-close ws)

Modules

ModuleDescription
(sigil websocket)Top-level re-exports
(sigil websocket frame)Frame encoding, decoding, masking
(sigil websocket connection)Handshake, send, receive, close

Dependencies

  • sigil-stdlib
  • sigil-socket
  • sigil-crypto

Building

sigil deps install
sigil build
sigil test

License

BSD-3-Clause