- (ws-connect STRING #!optional (list WS-EXTENSION ...) (list SYMBOL ...)) -> (or WS-CONNECTION RECORD)procedure
The state of a WebSocket connection is stored in a record of type ws-connection.
The procedure ws-connect attempts to establish a WebSocket connection to a server. The argument STRING should be a valid WebSocket URI.
If the opening handshake for the WebSocket protocol succeeds, this procedure returns a ws-connection record. If it receives a HTTP response from the server with status code other than 101, it instead returns a record containing the HTTP response (see intarweb). The user should call is-ws-connection? on the result of ws-connect to check if this has happened and, in the case of an unsuccessful handshake, process the HTTP response accordingly, e.g. by following a redirect.
To use WebSockets over TLS, supply a URI with scheme wss.
The procedure ws-connect optionally accepts a list of extensions the client hopes to use. The only extension currently supported by this library is permessage-deflate; see the relevant section.
The second optional argument is a list of flags (symbols). The only one currently supported is 'strip-host, which strips the hostname, port, and scheme from the method line of the client handshake. Some non-compliant implementations seem to require this.