:- use_module(library(http/websocket)). [det]ws_open(+Stream, 
-WSStream, +Options)
[det]ws_open(+Stream, 
-WSStream, +Options)server or client. If client, 
messages are sent as masked.true (default), closing WSStream also closes Stream.subprotocols option of http_open_websocket/3 
and
http_upgrade_to_websocket/3.A typical sequence to turn a pair of streams into a WebSocket is here:
    ...,
    Options = [mode(server), subprotocol(chat)],
    ws_open(Input, WsInput, Options),
    ws_open(Output, WsOutput, Options),
    stream_pair(WebSocket, WsInput, WsOutput).