1NN_WS(7)                         nanomsg 1.1.5                        NN_WS(7)
2
3
4

NAME

6       nn_ws - WebSocket transport mechanism
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       #include <nanomsg/ws.h>
12

DESCRIPTION

14       The WebSocket transport uses the framing protocol specified in RFC 6455
15       to transport messages. The initial handshake is done using HTTP
16       headers, with the Sec-Websocket-Protocol header set to the SP protocol
17       used by the server. For example, a REQ client will send
18       rep.sp.nanomsg.org.
19
20       Each SP message is transported in a single WebSocket frame, with no
21       additional data or headers applied. By default this library sends and
22       expects to receive binary frames.
23
24       When calling either nn_bind() or nn_connect(), omitting the port
25       defaults to the RFC 6455 default port 80 for HTTP. For example,
26       ws://127.0.0.1 is equivalent to ws://127.0.0.1:80
27
28       WebSocket over TLS is not supported by this library, at this time.
29
30   URI limitations
31       When calling nn_connect(), the URI may also optionally include the path
32       to a resource and/or query parameters.
33
34       Example 1. Path and query parameters
35
36               s1 = nn_socket (AF_SP, NN_PAIR);
37               nn_connect (s1, "ws://example.com/path?query=value");
38
39       This implementation includes the full path and any query parameters in
40       the HTTP handshake when establishing connections with nn_connect().
41       This information is not available via the nanomsg API afterwards,
42       however.
43
44       Likewise, this implementation does not examine or use either any path
45       or query parameters that may be supplied to nn_bind(), as it only binds
46       to the TCP port. This implementation acts as a limited HTTP server that
47       offers SP over WebSocket at all URIs for the given TCP address.
48
49       Applications, however, should not depend on this behavior; intervening
50       infrastructure may proxy, filter or route based on URI, and other
51       implementations of the SP over WebSocket protocol may offer other HTTP
52       services at the same TCP port, utilizing the path, query parameters, or
53       both to determine the service to be used.
54
55   Socket Options
56       NN_WS_MSG_TYPE
57           This option may be set to NN_WS_MSG_TYPE_TEXT or
58           NN_WS_MSG_TYPE_BINARY. The value of this determines whether data
59           messages are sent as WebSocket text frames, or binary frames, per
60           RFC 6455. Text frames should contain only valid UTF-8 text in their
61           payload, or they will be rejected. Binary frames may contain any
62           data. Not all WebSocket implementations support binary frames. The
63           default is to send binary frames.
64
65           This option may also be specified as control data when when sending
66           a message with nn_sendmsg().
67
68       TODO: NN_TCP_NODELAY
69           This option, when set to 1, disables Nagle’s algorithm. It also
70           disables delaying of TCP acknowledgments. Using this option
71           improves latency at the expense of throughput. Type of this option
72           is int. Default value is 0.
73

EXAMPLE

75           nn_bind (s1, "ws://*:5555");
76           nn_connect (s2, "ws://myserver:5555");
77

SEE ALSO

79       nn_tcp(7) nn_inproc(7) nn_ipc(7) nn_bind(3) nn_connect(3) nanomsg(7)
80

AUTHORS

82       Martin Sustrik <sustrik@250bpm.com> Jack R. Dunaway
83       <jack@wirebirdlabs.com> Garrett D’Amore <garrett@damore.org>
84
85
86
87                                  2020-01-29                          NN_WS(7)
Impressum