The fast-websocket Reference Manual

This is the fast-websocket Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 05:12:41 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 fast-websocket

Optimized WebSocket protocol parser

Author

Eitaro Fukamachi

License

BSD 2-Clause

Long Description

# fast-websocket

[![Build Status](https://travis-ci.org/fukamachi/fast-websocket.svg?branch=master)](https://travis-ci.org/fukamachi/fast-websocket) [![Coverage Status](https://coveralls.io/repos/fukamachi/fast-websocket/badge.svg?branch=master)](https://coveralls.io/r/fukamachi/fast-websocket) [![Quicklisp dist](http://quickdocs.org/badge/fast-websocket.svg)](http://quickdocs.org/fast-websocket/)

Optimized low-level WebSocket protocol parser/composer.

## Warning

This software is still BETA quality. The APIs will be likely to change.

## Usage

“‘common-lisp
(use-package :fast-websocket)

(let* ((ws (make-ws))
(body (make-string-output-stream))
(parser (make-parser ws
:require-masking t
:message-callback
(lambda (message)
(princ message body))
:close-callback
(lambda (payload &key code)
(format t "Client closed a connection: ~A (Code: ~D)~%" payload code)))))
(funcall parser (make-array 11 :element-type ’(unsigned-byte 8)
:initial-contents (list 129 133 225 106 10 29 169 15 102 113 142)))

(princ (opcode-name (ws-opcode ws)))
;-> :TEXT

(princ (get-output-stream-string body))
;-> Hello

t)

(compose-frame "bye" :type :close :code (error-code :protocol-error))
;=> #(136 5 3 234 98 121 101)
“‘

## Installation

“‘
cd ~/common-lisp
git clone https://github.com/fukamachi/fast-websocket
“‘

“‘
(ql:quickload :fast-websocket)
“‘

## See Also

* [RFC 6455](https://tools.ietf.org/html/rfc6455)
* [websocket-driver](https://github.com/fukamachi/websocket-driver)

## Author

* Eitaro Fukamachi (e.arrows@gmail.com)

## Copyright

Copyright (c) 2015 Eitaro Fukamachi (e.arrows@gmail.com)

## License

Licensed under the BSD 2-Clause License.

Version

0.1

Dependencies
  • fast-io (system).
  • babel (system).
  • alexandria (system).
Source

fast-websocket.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


3.1 fast-websocket/src

Source

fast-websocket.asd.

Parent Component

fast-websocket (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 fast-websocket/fast-websocket.asd

Source

fast-websocket.asd.

Parent Component

fast-websocket (system).

ASDF Systems

fast-websocket.

Packages

fast-websocket-asd.


4.1.2 fast-websocket/src/fast-websocket.lisp

Dependencies
Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.

Public Interface

make-parser (function).

Internals

make-payload-callback (function).


4.1.3 fast-websocket/src/ws.lisp

Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.ws.

Public Interface
Internals

4.1.4 fast-websocket/src/parser.lisp

Dependencies
Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.parser.

Public Interface

make-ll-parser (function).

Internals

4.1.5 fast-websocket/src/compose.lisp

Dependencies
Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.compose.

Public Interface

compose-frame (function).

Internals

4.1.6 fast-websocket/src/payload.lisp

Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.payload.

Public Interface
Internals

4.1.7 fast-websocket/src/constants.lisp

Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.constants.

Public Interface
Internals

4.1.8 fast-websocket/src/error.lisp

Source

fast-websocket.asd.

Parent Component

src (module).

Packages

fast-websocket.error.

Public Interface
Internals

5 Packages

Packages are listed by definition order.


5.1 fast-websocket

Source

fast-websocket.lisp.

Use List
Public Interface

make-parser (function).

Internals

make-payload-callback (function).


5.2 fast-websocket.constants

Source

constants.lisp.

Use List

common-lisp.

Used By List
Public Interface
Internals

5.3 fast-websocket.parser

Source

parser.lisp.

Use List
Public Interface

make-ll-parser (function).

Internals

5.4 fast-websocket.compose

Source

compose.lisp.

Use List
Public Interface

compose-frame (function).

Internals

5.5 fast-websocket.payload

Source

payload.lisp.

Use List

common-lisp.

Public Interface
Internals

5.6 fast-websocket-asd

Source

fast-websocket.asd.

Use List
  • asdf/interface.
  • common-lisp.

5.7 fast-websocket.ws

Source

ws.lisp.

Use List

common-lisp.

Used By List
Public Interface
Internals

5.8 fast-websocket.error

Source

error.lisp.

Use List

common-lisp.

Used By List

fast-websocket.parser.

Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Constants

Constant: +byte+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +fin+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +length+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +mask+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +opcode+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +rsv1+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +rsv2+
Package

fast-websocket.constants.

Source

constants.lisp.

Constant: +rsv3+
Package

fast-websocket.constants.

Source

constants.lisp.


6.1.2 Ordinary functions

Function: acceptable-error-code-p (code)
Package

fast-websocket.error.

Source

error.lisp.

Function: compose-frame (data &key start end type code masking)
Package

fast-websocket.compose.

Source

compose.lisp.

Function: error-code (error)
Package

fast-websocket.error.

Source

error.lisp.

Function: error-code-name (code)
Package

fast-websocket.error.

Source

error.lisp.

Function: fast-write-masked-sequence (data output-buffer mask-keys &optional start end)
Package

fast-websocket.payload.

Source

payload.lisp.

Function: fragmented-opcode-p (opcode)
Package

fast-websocket.constants.

Source

constants.lisp.

Function: make-ll-parser (ws &key require-masking max-length payload-callback)
Package

fast-websocket.parser.

Source

parser.lisp.

Function: make-parser (ws &key require-masking max-length message-callback ping-callback pong-callback close-callback error-callback)
Package

fast-websocket.

Source

fast-websocket.lisp.

Function: make-ws (&key fin opcode mask masking-key length length-size mode stage)
Package

fast-websocket.ws.

Source

ws.lisp.

Function: mask-message (data mask-keys)
Package

fast-websocket.payload.

Source

payload.lisp.

Function: opcode (name)
Package

fast-websocket.constants.

Source

constants.lisp.

Function: opcode-name (opcode)
Package

fast-websocket.constants.

Source

constants.lisp.

Function: opening-opcode-p (opcode)
Package

fast-websocket.constants.

Source

constants.lisp.

Function: valid-error-code-p (code)
Package

fast-websocket.error.

Source

error.lisp.

Function: valid-opcode-p (opcode)
Package

fast-websocket.constants.

Source

constants.lisp.

Reader: ws-fin (instance)
Writer: (setf ws-fin) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

fin.

Reader: ws-length (instance)
Writer: (setf ws-length) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

length.

Reader: ws-length-size (instance)
Writer: (setf ws-length-size) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

length-size.

Reader: ws-mask (instance)
Writer: (setf ws-mask) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

mask.

Reader: ws-masking-key (instance)
Writer: (setf ws-masking-key) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

masking-key.

Reader: ws-mode (instance)
Writer: (setf ws-mode) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

mode.

Reader: ws-opcode (instance)
Writer: (setf ws-opcode) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

opcode.

Reader: ws-stage (instance)
Writer: (setf ws-stage) (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Target Slot

stage.


6.1.3 Conditions

Condition: encoding-error
Package

fast-websocket.error.

Source

error.lisp.

Direct superclasses

protocol-error.

Condition: protocol-error
Package

fast-websocket.error.

Source

error.lisp.

Direct superclasses
Direct subclasses
Condition: too-large
Package

fast-websocket.error.

Source

error.lisp.

Direct superclasses

protocol-error.

Direct slots
Slot: length
Package

common-lisp.

Initargs

:length

Slot: max-length
Initargs

:max-length

Condition: unacceptable
Package

fast-websocket.error.

Source

error.lisp.

Direct superclasses

protocol-error.

Direct slots
Slot: require-masking
Initargs

:require-masking

Condition: websocket-error
Package

fast-websocket.error.

Source

error.lisp.

Direct superclasses

error.

Direct subclasses

websocket-parse-error.

Condition: websocket-parse-error
Package

fast-websocket.error.

Source

error.lisp.

Direct superclasses

websocket-error.

Direct subclasses

protocol-error.


6.1.4 Structures

Structure: ws
Package

fast-websocket.ws.

Source

ws.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: fin
Type

boolean

Readers

ws-fin.

Writers

(setf ws-fin).

Slot: opcode
Type

fixnum

Initform

-1

Readers

ws-opcode.

Writers

(setf ws-opcode).

Slot: mask
Type

boolean

Readers

ws-mask.

Writers

(setf ws-mask).

Slot: masking-key
Type

(simple-array (unsigned-byte 8) (4))

Initform

(make-array 4 :element-type (quote (unsigned-byte 8)))

Readers

ws-masking-key.

Writers

(setf ws-masking-key).

Slot: length
Package

common-lisp.

Type

integer

Initform

0

Readers

ws-length.

Writers

(setf ws-length).

Slot: length-size
Type

fixnum

Initform

0

Readers

ws-length-size.

Writers

(setf ws-length-size).

Slot: mode
Type

symbol

Readers

ws-mode.

Writers

(setf ws-mode).

Slot: stage
Type

fixnum

Initform

0

Readers

ws-stage.

Writers

(setf ws-stage).


6.2 Internals


6.2.1 Constants

Constant: +max-reserved-error+
Package

fast-websocket.error.

Source

error.lisp.

Constant: +min-reserved-error+
Package

fast-websocket.error.

Source

error.lisp.


6.2.2 Special variables

Special Variable: *error-codes*
Package

fast-websocket.error.

Source

error.lisp.

Special Variable: *error-codes-map*
Package

fast-websocket.error.

Source

error.lisp.

Special Variable: *error-codes-name-map*
Package

fast-websocket.error.

Source

error.lisp.

Special Variable: *fragmented-opcodes*
Package

fast-websocket.constants.

Source

constants.lisp.

Special Variable: *mask-key-indices*
Package

fast-websocket.payload.

Source

payload.lisp.

Special Variable: *mask-random-state*
Package

fast-websocket.compose.

Source

compose.lisp.

Special Variable: *opcode-valid-array*
Package

fast-websocket.constants.

Source

constants.lisp.

Special Variable: *opcodes-map*
Package

fast-websocket.constants.

Source

constants.lisp.

Special Variable: *opcodes-name-map*
Package

fast-websocket.constants.

Source

constants.lisp.

Special Variable: *opening-opcodes*
Package

fast-websocket.constants.

Source

constants.lisp.


6.2.3 Macros

Macro: with-masking ((byte data &key start end mask-keys i) &body body)
Package

fast-websocket.payload.

Source

payload.lisp.


6.2.4 Ordinary functions

Function: copy-ws (instance)
Package

fast-websocket.ws.

Source

ws.lisp.

Function: make-payload-callback (ws message-callback ping-callback pong-callback close-callback)
Package

fast-websocket.

Source

fast-websocket.lisp.

Function: mask-byte (byte mask-key)
Package

fast-websocket.payload.

Source

payload.lisp.

Function: random-mask-keys ()
Package

fast-websocket.compose.

Source

compose.lisp.

Function: ws-p (object)
Package

fast-websocket.ws.

Source

ws.lisp.


6.2.5 Types

Type: octet ()
Package

fast-websocket.parser.

Source

parser.lisp.

Type: octets ()
Package

fast-websocket.parser.

Source

parser.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
A   C   E   F   M   O   R   V   W  
Index Entry  Section

(
(setf ws-fin): Public ordinary functions
(setf ws-length): Public ordinary functions
(setf ws-length-size): Public ordinary functions
(setf ws-mask): Public ordinary functions
(setf ws-masking-key): Public ordinary functions
(setf ws-mode): Public ordinary functions
(setf ws-opcode): Public ordinary functions
(setf ws-stage): Public ordinary functions

A
acceptable-error-code-p: Public ordinary functions

C
compose-frame: Public ordinary functions
copy-ws: Private ordinary functions

E
error-code: Public ordinary functions
error-code-name: Public ordinary functions

F
fast-write-masked-sequence: Public ordinary functions
fragmented-opcode-p: Public ordinary functions
Function, (setf ws-fin): Public ordinary functions
Function, (setf ws-length): Public ordinary functions
Function, (setf ws-length-size): Public ordinary functions
Function, (setf ws-mask): Public ordinary functions
Function, (setf ws-masking-key): Public ordinary functions
Function, (setf ws-mode): Public ordinary functions
Function, (setf ws-opcode): Public ordinary functions
Function, (setf ws-stage): Public ordinary functions
Function, acceptable-error-code-p: Public ordinary functions
Function, compose-frame: Public ordinary functions
Function, copy-ws: Private ordinary functions
Function, error-code: Public ordinary functions
Function, error-code-name: Public ordinary functions
Function, fast-write-masked-sequence: Public ordinary functions
Function, fragmented-opcode-p: Public ordinary functions
Function, make-ll-parser: Public ordinary functions
Function, make-parser: Public ordinary functions
Function, make-payload-callback: Private ordinary functions
Function, make-ws: Public ordinary functions
Function, mask-byte: Private ordinary functions
Function, mask-message: Public ordinary functions
Function, opcode: Public ordinary functions
Function, opcode-name: Public ordinary functions
Function, opening-opcode-p: Public ordinary functions
Function, random-mask-keys: Private ordinary functions
Function, valid-error-code-p: Public ordinary functions
Function, valid-opcode-p: Public ordinary functions
Function, ws-fin: Public ordinary functions
Function, ws-length: Public ordinary functions
Function, ws-length-size: Public ordinary functions
Function, ws-mask: Public ordinary functions
Function, ws-masking-key: Public ordinary functions
Function, ws-mode: Public ordinary functions
Function, ws-opcode: Public ordinary functions
Function, ws-p: Private ordinary functions
Function, ws-stage: Public ordinary functions

M
Macro, with-masking: Private macros
make-ll-parser: Public ordinary functions
make-parser: Public ordinary functions
make-payload-callback: Private ordinary functions
make-ws: Public ordinary functions
mask-byte: Private ordinary functions
mask-message: Public ordinary functions

O
opcode: Public ordinary functions
opcode-name: Public ordinary functions
opening-opcode-p: Public ordinary functions

R
random-mask-keys: Private ordinary functions

V
valid-error-code-p: Public ordinary functions
valid-opcode-p: Public ordinary functions

W
with-masking: Private macros
ws-fin: Public ordinary functions
ws-length: Public ordinary functions
ws-length-size: Public ordinary functions
ws-mask: Public ordinary functions
ws-masking-key: Public ordinary functions
ws-mode: Public ordinary functions
ws-opcode: Public ordinary functions
ws-p: Private ordinary functions
ws-stage: Public ordinary functions


A.3 Variables

Jump to:   *   +  
C   F   L   M   O   R   S  
Index Entry  Section

*
*error-codes*: Private special variables
*error-codes-map*: Private special variables
*error-codes-name-map*: Private special variables
*fragmented-opcodes*: Private special variables
*mask-key-indices*: Private special variables
*mask-random-state*: Private special variables
*opcode-valid-array*: Private special variables
*opcodes-map*: Private special variables
*opcodes-name-map*: Private special variables
*opening-opcodes*: Private special variables

+
+byte+: Public constants
+fin+: Public constants
+length+: Public constants
+mask+: Public constants
+max-reserved-error+: Private constants
+min-reserved-error+: Private constants
+opcode+: Public constants
+rsv1+: Public constants
+rsv2+: Public constants
+rsv3+: Public constants

C
Constant, +byte+: Public constants
Constant, +fin+: Public constants
Constant, +length+: Public constants
Constant, +mask+: Public constants
Constant, +max-reserved-error+: Private constants
Constant, +min-reserved-error+: Private constants
Constant, +opcode+: Public constants
Constant, +rsv1+: Public constants
Constant, +rsv2+: Public constants
Constant, +rsv3+: Public constants

F
fin: Public structures

L
length: Public conditions
length: Public structures
length-size: Public structures

M
mask: Public structures
masking-key: Public structures
max-length: Public conditions
mode: Public structures

O
opcode: Public structures

R
require-masking: Public conditions

S
Slot, fin: Public structures
Slot, length: Public conditions
Slot, length: Public structures
Slot, length-size: Public structures
Slot, mask: Public structures
Slot, masking-key: Public structures
Slot, max-length: Public conditions
Slot, mode: Public structures
Slot, opcode: Public structures
Slot, require-masking: Public conditions
Slot, stage: Public structures
Special Variable, *error-codes*: Private special variables
Special Variable, *error-codes-map*: Private special variables
Special Variable, *error-codes-name-map*: Private special variables
Special Variable, *fragmented-opcodes*: Private special variables
Special Variable, *mask-key-indices*: Private special variables
Special Variable, *mask-random-state*: Private special variables
Special Variable, *opcode-valid-array*: Private special variables
Special Variable, *opcodes-map*: Private special variables
Special Variable, *opcodes-name-map*: Private special variables
Special Variable, *opening-opcodes*: Private special variables
stage: Public structures


A.4 Data types

Jump to:   C   E   F   M   O   P   S   T   U   W  
Index Entry  Section

C
compose.lisp: The fast-websocket/src/compose․lisp file
Condition, encoding-error: Public conditions
Condition, protocol-error: Public conditions
Condition, too-large: Public conditions
Condition, unacceptable: Public conditions
Condition, websocket-error: Public conditions
Condition, websocket-parse-error: Public conditions
constants.lisp: The fast-websocket/src/constants․lisp file

E
encoding-error: Public conditions
error.lisp: The fast-websocket/src/error․lisp file

F
fast-websocket: The fast-websocket system
fast-websocket: The fast-websocket package
fast-websocket-asd: The fast-websocket-asd package
fast-websocket.asd: The fast-websocket/fast-websocket․asd file
fast-websocket.compose: The fast-websocket․compose package
fast-websocket.constants: The fast-websocket․constants package
fast-websocket.error: The fast-websocket․error package
fast-websocket.lisp: The fast-websocket/src/fast-websocket․lisp file
fast-websocket.parser: The fast-websocket․parser package
fast-websocket.payload: The fast-websocket․payload package
fast-websocket.ws: The fast-websocket․ws package
File, compose.lisp: The fast-websocket/src/compose․lisp file
File, constants.lisp: The fast-websocket/src/constants․lisp file
File, error.lisp: The fast-websocket/src/error․lisp file
File, fast-websocket.asd: The fast-websocket/fast-websocket․asd file
File, fast-websocket.lisp: The fast-websocket/src/fast-websocket․lisp file
File, parser.lisp: The fast-websocket/src/parser․lisp file
File, payload.lisp: The fast-websocket/src/payload․lisp file
File, ws.lisp: The fast-websocket/src/ws․lisp file

M
Module, src: The fast-websocket/src module

O
octet: Private types
octets: Private types

P
Package, fast-websocket: The fast-websocket package
Package, fast-websocket-asd: The fast-websocket-asd package
Package, fast-websocket.compose: The fast-websocket․compose package
Package, fast-websocket.constants: The fast-websocket․constants package
Package, fast-websocket.error: The fast-websocket․error package
Package, fast-websocket.parser: The fast-websocket․parser package
Package, fast-websocket.payload: The fast-websocket․payload package
Package, fast-websocket.ws: The fast-websocket․ws package
parser.lisp: The fast-websocket/src/parser․lisp file
payload.lisp: The fast-websocket/src/payload․lisp file
protocol-error: Public conditions

S
src: The fast-websocket/src module
Structure, ws: Public structures
System, fast-websocket: The fast-websocket system

T
too-large: Public conditions
Type, octet: Private types
Type, octets: Private types

U
unacceptable: Public conditions

W
websocket-error: Public conditions
websocket-parse-error: Public conditions
ws: Public structures
ws.lisp: The fast-websocket/src/ws․lisp file