blob: fb14ef07461ac1b4089d87d8b2e02bc3fe7c0694 [file] [log] [blame]
Andy Greend88146d2013-01-22 12:40:35 +08001<h2>libwebsocket_client_connect - Connect to another websocket server</h2>
2<i>struct libwebsocket *</i>
3<b>libwebsocket_client_connect</b>
4(<i>struct libwebsocket_context *</i> <b>context</b>,
5<i>const char *</i> <b>address</b>,
6<i>int</i> <b>port</b>,
7<i>int</i> <b>ssl_connection</b>,
8<i>const char *</i> <b>path</b>,
9<i>const char *</i> <b>host</b>,
10<i>const char *</i> <b>origin</b>,
11<i>const char *</i> <b>protocol</b>,
12<i>int</i> <b>ietf_version_or_minus_one</b>)
13<h3>Arguments</h3>
14<dl>
15<dt><b>context</b>
16<dd>Websocket context
17<dt><b>address</b>
18<dd>Remote server address, eg, "myserver.com"
19<dt><b>port</b>
20<dd>Port to connect to on the remote server, eg, 80
21<dt><b>ssl_connection</b>
22<dd>0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
23signed certs
24<dt><b>path</b>
25<dd>Websocket path on server
26<dt><b>host</b>
27<dd>Hostname on server
28<dt><b>origin</b>
29<dd>Socket origin name
30<dt><b>protocol</b>
31<dd>Comma-separated list of protocols being asked for from
32the server, or just one. The server will pick the one it
33likes best.
34<dt><b>ietf_version_or_minus_one</b>
35<dd>-1 to ask to connect using the default, latest
36protocol supported, or the specific protocol ordinal
37</dl>
38<h3>Description</h3>
39<blockquote>
40This function creates a connection to a remote server
41</blockquote>
42<hr>
43<h2>libwebsocket_client_connect_extended - Connect to another websocket server</h2>
44<i>struct libwebsocket *</i>
45<b>libwebsocket_client_connect_extended</b>
46(<i>struct libwebsocket_context *</i> <b>context</b>,
47<i>const char *</i> <b>address</b>,
48<i>int</i> <b>port</b>,
49<i>int</i> <b>ssl_connection</b>,
50<i>const char *</i> <b>path</b>,
51<i>const char *</i> <b>host</b>,
52<i>const char *</i> <b>origin</b>,
53<i>const char *</i> <b>protocol</b>,
54<i>int</i> <b>ietf_version_or_minus_one</b>,
55<i>void *</i> <b>userdata</b>)
56<h3>Arguments</h3>
57<dl>
58<dt><b>context</b>
59<dd>Websocket context
60<dt><b>address</b>
61<dd>Remote server address, eg, "myserver.com"
62<dt><b>port</b>
63<dd>Port to connect to on the remote server, eg, 80
64<dt><b>ssl_connection</b>
65<dd>0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
66signed certs
67<dt><b>path</b>
68<dd>Websocket path on server
69<dt><b>host</b>
70<dd>Hostname on server
71<dt><b>origin</b>
72<dd>Socket origin name
73<dt><b>protocol</b>
74<dd>Comma-separated list of protocols being asked for from
75the server, or just one. The server will pick the one it
76likes best.
77<dt><b>ietf_version_or_minus_one</b>
78<dd>-1 to ask to connect using the default, latest
79protocol supported, or the specific protocol ordinal
80<dt><b>userdata</b>
81<dd>Pre-allocated user data
82</dl>
83<h3>Description</h3>
84<blockquote>
85This function creates a connection to a remote server
86</blockquote>
87<hr>
Andy Green7b405452013-02-01 10:50:15 +080088<h2>lws_get_library_version - </h2>
89<i>const char *</i>
90<b>lws_get_library_version</b>
91(<i></i> <b>void</b>)
92<h3>Arguments</h3>
93<dl>
94<dt><b>void</b>
95<dd>no arguments
96</dl>
97<h3>Description</h3>
98<blockquote>
99<p>
100returns a const char * to a string like "1.1 178d78c"
101representing the library version followed by the git head hash it
102was built from
103</blockquote>
104<hr>
Andy Greenf7ee5492011-02-13 09:04:21 +0000105<h2>libwebsockets_hangup_on_client - Server calls to terminate client connection</h2>
106<i>void</i>
107<b>libwebsockets_hangup_on_client</b>
Peter Hinz56885f32011-03-02 22:03:47 +0000108(<i>struct libwebsocket_context *</i> <b>context</b>,
Andy Greenf7ee5492011-02-13 09:04:21 +0000109<i>int</i> <b>fd</b>)
110<h3>Arguments</h3>
111<dl>
Peter Hinz56885f32011-03-02 22:03:47 +0000112<dt><b>context</b>
Andy Greenf7ee5492011-02-13 09:04:21 +0000113<dd>libwebsockets context
114<dt><b>fd</b>
115<dd>Connection socket descriptor
116</dl>
117<hr>
Andy Green07034092011-02-13 08:37:12 +0000118<h2>libwebsockets_get_peer_addresses - Get client address information</h2>
119<i>void</i>
120<b>libwebsockets_get_peer_addresses</b>
Andy Greenaaf0b9f2013-01-30 08:12:20 +0800121(<i>struct libwebsocket_context *</i> <b>context</b>,
122<i>struct libwebsocket *</i> <b>wsi</b>,
123<i>int</i> <b>fd</b>,
Andy Green07034092011-02-13 08:37:12 +0000124<i>char *</i> <b>name</b>,
125<i>int</i> <b>name_len</b>,
126<i>char *</i> <b>rip</b>,
127<i>int</i> <b>rip_len</b>)
128<h3>Arguments</h3>
129<dl>
Andy Greenaaf0b9f2013-01-30 08:12:20 +0800130<dt><b>context</b>
131<dd>Libwebsockets context
132<dt><b>wsi</b>
133<dd>Local struct libwebsocket associated with
Andy Green07034092011-02-13 08:37:12 +0000134<dt><b>fd</b>
135<dd>Connection socket descriptor
136<dt><b>name</b>
137<dd>Buffer to take client address name
138<dt><b>name_len</b>
139<dd>Length of client address name buffer
140<dt><b>rip</b>
141<dd>Buffer to take client address IP qotted quad
142<dt><b>rip_len</b>
143<dd>Length of client address IP buffer
144</dl>
145<h3>Description</h3>
146<blockquote>
147This function fills in <tt><b>name</b></tt> and <tt><b>rip</b></tt> with the name and IP of
148the client connected with socket descriptor <tt><b>fd</b></tt>. Names may be
149truncated if there is not enough room. If either cannot be
150determined, they will be returned as valid zero-length strings.
151</blockquote>
152<hr>
Andy Green9f990342011-02-12 11:57:45 +0000153<h2>libwebsocket_service_fd - Service polled socket with something waiting</h2>
154<i>int</i>
155<b>libwebsocket_service_fd</b>
Peter Hinz56885f32011-03-02 22:03:47 +0000156(<i>struct libwebsocket_context *</i> <b>context</b>,
Andy Green9f990342011-02-12 11:57:45 +0000157<i>struct pollfd *</i> <b>pollfd</b>)
158<h3>Arguments</h3>
159<dl>
Peter Hinz56885f32011-03-02 22:03:47 +0000160<dt><b>context</b>
Andy Green9f990342011-02-12 11:57:45 +0000161<dd>Websocket context
162<dt><b>pollfd</b>
163<dd>The pollfd entry describing the socket fd and which events
164happened.
165</dl>
166<h3>Description</h3>
167<blockquote>
Andy Green75006172013-01-22 12:32:11 +0800168This function takes a pollfd that has POLLIN or POLLOUT activity and
169services it according to the state of the associated struct libwebsocket.
170<p>
171The one call deals with all "service" that might happen on a socket
172including listen accepts, http files as well as websocket protocol.
Andy Green9f990342011-02-12 11:57:45 +0000173</blockquote>
174<hr>
Andy Green6964bb52011-01-23 16:50:33 +0000175<h2>libwebsocket_context_destroy - Destroy the websocket context</h2>
176<i>void</i>
177<b>libwebsocket_context_destroy</b>
Peter Hinz56885f32011-03-02 22:03:47 +0000178(<i>struct libwebsocket_context *</i> <b>context</b>)
Andy Green6964bb52011-01-23 16:50:33 +0000179<h3>Arguments</h3>
180<dl>
Peter Hinz56885f32011-03-02 22:03:47 +0000181<dt><b>context</b>
Andy Green6964bb52011-01-23 16:50:33 +0000182<dd>Websocket context
183</dl>
184<h3>Description</h3>
185<blockquote>
186This function closes any active connections and then frees the
187context. After calling this, any further use of the context is
188undefined.
189</blockquote>
190<hr>
Andy Greend88146d2013-01-22 12:40:35 +0800191<h2>libwebsocket_context_user - get the user data associated with the whole context</h2>
192<i>LWS_EXTERN void *</i>
193<b>libwebsocket_context_user</b>
194(<i>struct libwebsocket_context *</i> <b>context</b>)
195<h3>Arguments</h3>
196<dl>
197<dt><b>context</b>
198<dd>Websocket context
199</dl>
200<h3>Description</h3>
201<blockquote>
202This returns the optional user allocation that can be attached to
203the context the sockets live in at context_create time. It's a way
204to let all sockets serviced in the same context share data without
205using globals statics in the user code.
206</blockquote>
207<hr>
Andy Green6964bb52011-01-23 16:50:33 +0000208<h2>libwebsocket_service - Service any pending websocket activity</h2>
209<i>int</i>
210<b>libwebsocket_service</b>
Peter Hinz56885f32011-03-02 22:03:47 +0000211(<i>struct libwebsocket_context *</i> <b>context</b>,
Andy Green6964bb52011-01-23 16:50:33 +0000212<i>int</i> <b>timeout_ms</b>)
213<h3>Arguments</h3>
214<dl>
Peter Hinz56885f32011-03-02 22:03:47 +0000215<dt><b>context</b>
Andy Green6964bb52011-01-23 16:50:33 +0000216<dd>Websocket context
217<dt><b>timeout_ms</b>
218<dd>Timeout for poll; 0 means return immediately if nothing needed
219service otherwise block and service immediately, returning
220after the timeout if nothing needed service.
221</dl>
222<h3>Description</h3>
223<blockquote>
224This function deals with any pending websocket traffic, for three
225kinds of event. It handles these events on both server and client
226types of connection the same.
227<p>
2281) Accept new connections to our context's server
229<p>
Andy Green6f520a52013-01-29 17:57:39 +08002302) Call the receive callback for incoming frame data received by
Andy Green6964bb52011-01-23 16:50:33 +0000231server or client connections.
232<p>
233You need to call this service function periodically to all the above
234functions to happen; if your application is single-threaded you can
235just call it in your main event loop.
236<p>
237Alternatively you can fork a new process that asynchronously handles
238calling this service in a loop. In that case you are happy if this
239call blocks your thread until it needs to take care of something and
240would call it with a large nonzero timeout. Your loop then takes no
241CPU while there is nothing happening.
242<p>
243If you are calling it in a single-threaded app, you don't want it to
244wait around blocking other things in your loop from happening, so you
245would call it with a timeout_ms of 0, so it returns immediately if
246nothing is pending, or as soon as it services whatever was pending.
247</blockquote>
248<hr>
Andy Green32375b72011-02-19 08:32:53 +0000249<h2>libwebsocket_callback_on_writable - Request a callback when this socket becomes able to be written to without blocking</h2>
Andy Green90c7cbc2011-01-27 06:26:52 +0000250<i>int</i>
251<b>libwebsocket_callback_on_writable</b>
Peter Hinz56885f32011-03-02 22:03:47 +0000252(<i>struct libwebsocket_context *</i> <b>context</b>,
Andy Green62c54d22011-02-14 09:14:25 +0000253<i>struct libwebsocket *</i> <b>wsi</b>)
Andy Green90c7cbc2011-01-27 06:26:52 +0000254<h3>Arguments</h3>
255<dl>
Peter Hinz56885f32011-03-02 22:03:47 +0000256<dt><b>context</b>
Andy Green32375b72011-02-19 08:32:53 +0000257<dd>libwebsockets context
Andy Green90c7cbc2011-01-27 06:26:52 +0000258<dt><b>wsi</b>
259<dd>Websocket connection instance to get callback for
260</dl>
261<hr>
262<h2>libwebsocket_callback_on_writable_all_protocol - Request a callback for all connections using the given protocol when it becomes possible to write to each socket without blocking in turn.</h2>
263<i>int</i>
264<b>libwebsocket_callback_on_writable_all_protocol</b>
265(<i>const struct libwebsocket_protocols *</i> <b>protocol</b>)
266<h3>Arguments</h3>
267<dl>
268<dt><b>protocol</b>
269<dd>Protocol whose connections will get callbacks
270</dl>
271<hr>
Andy Greenbe93fef2011-02-14 20:25:43 +0000272<h2>libwebsocket_set_timeout - marks the wsi as subject to a timeout</h2>
273<i>void</i>
274<b>libwebsocket_set_timeout</b>
275(<i>struct libwebsocket *</i> <b>wsi</b>,
276<i>enum pending_timeout</i> <b>reason</b>,
277<i>int</i> <b>secs</b>)
278<h3>Arguments</h3>
279<dl>
280<dt><b>wsi</b>
281<dd>Websocket connection instance
282<dt><b>reason</b>
283<dd>timeout reason
284<dt><b>secs</b>
285<dd>how many seconds
286</dl>
287<h3>Description</h3>
288<blockquote>
289<p>
290You will not need this unless you are doing something special
291</blockquote>
292<hr>
Andy Greena6cbece2011-01-27 20:06:03 +0000293<h2>libwebsocket_get_socket_fd - returns the socket file descriptor</h2>
294<i>int</i>
295<b>libwebsocket_get_socket_fd</b>
296(<i>struct libwebsocket *</i> <b>wsi</b>)
297<h3>Arguments</h3>
298<dl>
299<dt><b>wsi</b>
300<dd>Websocket connection instance
301</dl>
302<h3>Description</h3>
303<blockquote>
304<p>
305You will not need this unless you are doing something special
306</blockquote>
307<hr>
Andy Green90c7cbc2011-01-27 06:26:52 +0000308<h2>libwebsocket_rx_flow_control - Enable and disable socket servicing for receieved packets.</h2>
309<i>int</i>
310<b>libwebsocket_rx_flow_control</b>
311(<i>struct libwebsocket *</i> <b>wsi</b>,
312<i>int</i> <b>enable</b>)
313<h3>Arguments</h3>
314<dl>
315<dt><b>wsi</b>
316<dd>Websocket connection instance to get callback for
317<dt><b>enable</b>
318<dd>0 = disable read servicing for this connection, 1 = enable
319</dl>
320<h3>Description</h3>
321<blockquote>
322<p>
323If the output side of a server process becomes choked, this allows flow
324control for the input side.
325</blockquote>
326<hr>
Andy Green2ac5a6f2011-01-28 10:00:18 +0000327<h2>libwebsocket_canonical_hostname - returns this host's hostname</h2>
328<i>const char *</i>
329<b>libwebsocket_canonical_hostname</b>
Peter Hinz56885f32011-03-02 22:03:47 +0000330(<i>struct libwebsocket_context *</i> <b>context</b>)
Andy Green2ac5a6f2011-01-28 10:00:18 +0000331<h3>Arguments</h3>
332<dl>
Peter Hinz56885f32011-03-02 22:03:47 +0000333<dt><b>context</b>
Andy Green2ac5a6f2011-01-28 10:00:18 +0000334<dd>Websocket context
335</dl>
336<h3>Description</h3>
337<blockquote>
338<p>
339This is typically used by client code to fill in the host parameter
340when making a client connection. You can only call it after the context
341has been created.
342</blockquote>
343<hr>
Andy Green4739e5c2011-01-22 12:51:57 +0000344<h2>libwebsocket_create_context - Create the websocket handler</h2>
Andy Greene92cd172011-01-19 13:11:55 +0000345<i>struct libwebsocket_context *</i>
Andy Green4739e5c2011-01-22 12:51:57 +0000346<b>libwebsocket_create_context</b>
Andy Green62a12932010-11-03 11:19:23 +0000347(<i>int</i> <b>port</b>,
Peter Hinz56885f32011-03-02 22:03:47 +0000348<i>const char *</i> <b>interf</b>,
Andy Greenb45993c2010-12-18 15:13:50 +0000349<i>struct libwebsocket_protocols *</i> <b>protocols</b>,
Andy Greend6e09112011-03-05 16:12:15 +0000350<i>struct libwebsocket_extension *</i> <b>extensions</b>,
Andy Green3faa9c72010-11-08 17:03:03 +0000351<i>const char *</i> <b>ssl_cert_filepath</b>,
352<i>const char *</i> <b>ssl_private_key_filepath</b>,
David Galeano2f82be82013-01-09 16:25:54 +0800353<i>const char *</i> <b>ssl_ca_filepath</b>,
Andy Green3faa9c72010-11-08 17:03:03 +0000354<i>int</i> <b>gid</b>,
Andy Green8014b292011-01-30 20:57:25 +0000355<i>int</i> <b>uid</b>,
Alon Levy0291eb32012-10-19 11:21:56 +0200356<i>unsigned int</i> <b>options</b>,
357<i>void *</i> <b>user</b>)
Andy Green62a12932010-11-03 11:19:23 +0000358<h3>Arguments</h3>
359<dl>
360<dt><b>port</b>
Andy Green4739e5c2011-01-22 12:51:57 +0000361<dd>Port to listen on... you can use 0 to suppress listening on
362any port, that's what you want if you are not running a
363websocket server at all but just using it as a client
Peter Hinz56885f32011-03-02 22:03:47 +0000364<dt><b>interf</b>
Andy Green32375b72011-02-19 08:32:53 +0000365<dd>NULL to bind the listen socket to all interfaces, or the
366interface name, eg, "eth2"
Andy Green4f3943a2010-11-12 10:44:16 +0000367<dt><b>protocols</b>
368<dd>Array of structures listing supported protocols and a protocol-
369specific callback for each one. The list is ended with an
370entry that has a NULL callback pointer.
Andy Greenb45993c2010-12-18 15:13:50 +0000371It's not const because we write the owning_server member
Andy Greenc5114822011-03-06 10:29:35 +0000372<dt><b>extensions</b>
373<dd>NULL or array of libwebsocket_extension structs listing the
Andy Green3182ece2013-01-20 17:08:31 +0800374extensions this context supports. If you configured with
375--without-extensions, you should give NULL here.
Andy Green3faa9c72010-11-08 17:03:03 +0000376<dt><b>ssl_cert_filepath</b>
377<dd>If libwebsockets was compiled to use ssl, and you want
378to listen using SSL, set to the filepath to fetch the
379server cert from, otherwise NULL for unencrypted
380<dt><b>ssl_private_key_filepath</b>
381<dd>filepath to private key if wanting SSL mode,
382else ignored
David Galeano2f82be82013-01-09 16:25:54 +0800383<dt><b>ssl_ca_filepath</b>
Andy Green988bd982013-01-10 12:26:13 +0800384<dd>CA certificate filepath or NULL
Andy Green3faa9c72010-11-08 17:03:03 +0000385<dt><b>gid</b>
386<dd>group id to change to after setting listen socket, or -1.
387<dt><b>uid</b>
388<dd>user id to change to after setting listen socket, or -1.
Andy Greenbfb051f2011-02-09 08:49:14 +0000389<dt><b>options</b>
390<dd>0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
Andy Green788c4a82012-10-22 12:29:57 +0100391<dt><b>user</b>
392<dd>optional user pointer that can be recovered via the context
393pointer using libwebsocket_context_user
Andy Green62a12932010-11-03 11:19:23 +0000394</dl>
395<h3>Description</h3>
396<blockquote>
Andy Green47943ae2010-11-12 11:15:49 +0000397This function creates the listening socket and takes care
Andy Green62a12932010-11-03 11:19:23 +0000398of all initialization in one step.
399<p>
Andy Greene92cd172011-01-19 13:11:55 +0000400After initialization, it returns a struct libwebsocket_context * that
401represents this server. After calling, user code needs to take care
402of calling <b>libwebsocket_service</b> with the context pointer to get the
403server's sockets serviced. This can be done in the same process context
404or a forked process, or another thread,
Andy Green47943ae2010-11-12 11:15:49 +0000405<p>
406The protocol callback functions are called for a handful of events
407including http requests coming in, websocket connections becoming
Andy Green62a12932010-11-03 11:19:23 +0000408established, and data arriving; it's also called periodically to allow
409async transmission.
410<p>
Andy Green47943ae2010-11-12 11:15:49 +0000411HTTP requests are sent always to the FIRST protocol in <tt><b>protocol</b></tt>, since
412at that time websocket protocol has not been negotiated. Other
413protocols after the first one never see any HTTP callack activity.
414<p>
Andy Green62a12932010-11-03 11:19:23 +0000415The server created is a simple http server by default; part of the
416websocket standard is upgrading this http connection to a websocket one.
417<p>
418This allows the same server to provide files like scripts and favicon /
419images or whatever over http and dynamic data over websockets all in
420one place; they're all handled in the user callback.
421</blockquote>
422<hr>
Andy Greenb45993c2010-12-18 15:13:50 +0000423<h2>libwebsockets_get_protocol - Returns a protocol pointer from a websocket connection.</h2>
424<i>const struct libwebsocket_protocols *</i>
425<b>libwebsockets_get_protocol</b>
426(<i>struct libwebsocket *</i> <b>wsi</b>)
427<h3>Arguments</h3>
428<dl>
429<dt><b>wsi</b>
430<dd>pointer to struct websocket you want to know the protocol of
431</dl>
432<h3>Description</h3>
433<blockquote>
434<p>
Andy Green6f520a52013-01-29 17:57:39 +0800435Some apis can act on all live connections of a given protocol,
436this is how you can get a pointer to the active protocol if needed.
Andy Greenacbaee62013-01-18 22:00:22 +0800437</blockquote>
438<hr>
Andy Green43db0452013-01-10 19:50:35 +0800439<h2>lws_set_log_level - Set the logging bitfield</h2>
440<i>void</i>
441<b>lws_set_log_level</b>
Andy Greende8f27a2013-01-12 09:17:42 +0800442(<i>int</i> <b>level</b>,
Andy Green058ba812013-01-19 11:32:18 +0800443<i>void (*</i><b>log_emit_function</b>) <i>(int level, const char *line)</i>)
Andy Green43db0452013-01-10 19:50:35 +0800444<h3>Arguments</h3>
445<dl>
446<dt><b>level</b>
447<dd>OR together the LLL_ debug contexts you want output from
Andy Greende8f27a2013-01-12 09:17:42 +0800448<dt><b>log_emit_function</b>
449<dd>NULL to leave it as it is, or a user-supplied
450function to perform log string emission instead of
451the default stderr one.
Andy Green43db0452013-01-10 19:50:35 +0800452</dl>
453<h3>Description</h3>
454<blockquote>
Andy Greende8f27a2013-01-12 09:17:42 +0800455log level defaults to "err" and "warn" contexts enabled only and
456emission on stderr.
Andy Green43db0452013-01-10 19:50:35 +0800457</blockquote>
458<hr>
Andy Greend88146d2013-01-22 12:40:35 +0800459<h2>libwebsocket_write - Apply protocol then write data to client</h2>
460<i>int</i>
461<b>libwebsocket_write</b>
462(<i>struct libwebsocket *</i> <b>wsi</b>,
463<i>unsigned char *</i> <b>buf</b>,
464<i>size_t</i> <b>len</b>,
465<i>enum libwebsocket_write_protocol</i> <b>protocol</b>)
466<h3>Arguments</h3>
467<dl>
468<dt><b>wsi</b>
469<dd>Websocket instance (available from user callback)
470<dt><b>buf</b>
471<dd>The data to send. For data being sent on a websocket
472connection (ie, not default http), this buffer MUST have
473LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE the pointer
474and an additional LWS_SEND_BUFFER_POST_PADDING bytes valid
475in the buffer after (buf + len). This is so the protocol
476header and trailer data can be added in-situ.
477<dt><b>len</b>
478<dd>Count of the data bytes in the payload starting from buf
479<dt><b>protocol</b>
480<dd>Use LWS_WRITE_HTTP to reply to an http connection, and one
481of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate
482data on a websockets connection. Remember to allow the extra
483bytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT
484are used.
485</dl>
486<h3>Description</h3>
487<blockquote>
488This function provides the way to issue data back to the client
489for both http and websocket protocols.
490<p>
491In the case of sending using websocket protocol, be sure to allocate
492valid storage before and after buf as explained above. This scheme
493allows maximum efficiency of sending data and protocol in a single
494packet while not burdening the user code with any protocol knowledge.
495</blockquote>
496<hr>
497<h2>libwebsockets_serve_http_file - Send a file back to the client using http</h2>
498<i>int</i>
499<b>libwebsockets_serve_http_file</b>
500(<i>struct libwebsocket_context *</i> <b>context</b>,
501<i>struct libwebsocket *</i> <b>wsi</b>,
502<i>const char *</i> <b>file</b>,
503<i>const char *</i> <b>content_type</b>)
504<h3>Arguments</h3>
505<dl>
506<dt><b>context</b>
507<dd>libwebsockets context
508<dt><b>wsi</b>
509<dd>Websocket instance (available from user callback)
510<dt><b>file</b>
511<dd>The file to issue over http
512<dt><b>content_type</b>
513<dd>The http content type, eg, text/html
514</dl>
515<h3>Description</h3>
516<blockquote>
517This function is intended to be called from the callback in response
518to http requests from the client. It allows the callback to issue
519local files down the http link in a single step.
520</blockquote>
521<hr>
Andy Green2fd3f2f2013-01-18 09:49:20 +0800522<h2>lws_frame_is_binary - </h2>
523<i>int</i>
524<b>lws_frame_is_binary</b>
525(<i>struct libwebsocket *</i> <b>wsi</b>)
526<h3>Arguments</h3>
527<dl>
528<dt><b>wsi</b>
529<dd>the connection we are inquiring about
530</dl>
531<h3>Description</h3>
532<blockquote>
533This is intended to be called from the LWS_CALLBACK_RECEIVE callback if
534it's interested to see if the frame it's dealing with was sent in binary
535mode.
536</blockquote>
537<hr>
Andy Green38e57bb2011-01-19 12:20:27 +0000538<h2>libwebsockets_remaining_packet_payload - Bytes to come before "overall" rx packet is complete</h2>
539<i>size_t</i>
540<b>libwebsockets_remaining_packet_payload</b>
541(<i>struct libwebsocket *</i> <b>wsi</b>)
542<h3>Arguments</h3>
543<dl>
544<dt><b>wsi</b>
545<dd>Websocket instance (available from user callback)
546</dl>
547<h3>Description</h3>
548<blockquote>
549This function is intended to be called from the callback if the
550user code is interested in "complete packets" from the client.
551libwebsockets just passes through payload as it comes and issues a buffer
552additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE
553callback handler can use this API to find out if the buffer it has just
554been given is the last piece of a "complete packet" from the client --
555when that is the case <b>libwebsockets_remaining_packet_payload</b> will return
5560.
557<p>
558Many protocols won't care becuse their packets are always small.
559</blockquote>
560<hr>
Andy Green8f037e42010-12-19 22:13:26 +0000561<h2>callback - User server actions</h2>
Andy Green07b56e62011-10-03 19:30:22 +0800562<i>LWS_EXTERN int</i>
Andy Green8f037e42010-12-19 22:13:26 +0000563<b>callback</b>
Darin Willitsc19456f2011-02-14 17:52:39 +0000564(<i>struct libwebsocket_context *</i> <b>context</b>,
Andy Green62c54d22011-02-14 09:14:25 +0000565<i>struct libwebsocket *</i> <b>wsi</b>,
Andy Green8f037e42010-12-19 22:13:26 +0000566<i>enum libwebsocket_callback_reasons</i> <b>reason</b>,
567<i>void *</i> <b>user</b>,
568<i>void *</i> <b>in</b>,
569<i>size_t</i> <b>len</b>)
570<h3>Arguments</h3>
571<dl>
Andy Green32375b72011-02-19 08:32:53 +0000572<dt><b>context</b>
573<dd>Websockets context
Andy Green8f037e42010-12-19 22:13:26 +0000574<dt><b>wsi</b>
575<dd>Opaque websocket instance pointer
576<dt><b>reason</b>
577<dd>The reason for the call
578<dt><b>user</b>
579<dd>Pointer to per-session user data allocated by library
580<dt><b>in</b>
581<dd>Pointer used for some callback reasons
582<dt><b>len</b>
583<dd>Length set for some callback reasons
584</dl>
585<h3>Description</h3>
586<blockquote>
587This callback is the way the user controls what is served. All the
588protocol detail is hidden and handled by the library.
589<p>
590For each connection / session there is user data allocated that is
591pointed to by "user". You set the size of this user data area when
592the library is initialized with libwebsocket_create_server.
593<p>
594You get an opportunity to initialize user data when called back with
595LWS_CALLBACK_ESTABLISHED reason.
596</blockquote>
597<h3>LWS_CALLBACK_ESTABLISHED</h3>
598<blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000599after the server completes a handshake with
600an incoming client
601</blockquote>
David Brooks2c60d952012-04-20 12:19:01 +0800602<h3>LWS_CALLBACK_CLIENT_CONNECTION_ERROR</h3>
603<blockquote>
604the request client connection has
605been unable to complete a handshake with the remote server
606</blockquote>
Andy Green2b57a342013-02-06 15:15:25 +0900607<h3>LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH</h3>
608<blockquote>
609this is the last chance for the
610client user code to examine the http headers
611and decide to reject the connection. If the
612content in the headers is interesting to the
613client (url, etc) it needs to copy it out at
614this point since it will be destroyed before
615the CLIENT_ESTABLISHED call
616</blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000617<h3>LWS_CALLBACK_CLIENT_ESTABLISHED</h3>
618<blockquote>
619after your client connection completed
620a handshake with the remote server
Andy Green8f037e42010-12-19 22:13:26 +0000621</blockquote>
622<h3>LWS_CALLBACK_CLOSED</h3>
623<blockquote>
624when the websocket session ends
625</blockquote>
Andy Green8f037e42010-12-19 22:13:26 +0000626<h3>LWS_CALLBACK_RECEIVE</h3>
627<blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000628data has appeared for this server endpoint from a
629remote client, it can be found at *in and is
630len bytes long
631</blockquote>
Andy Greena6cbece2011-01-27 20:06:03 +0000632<h3>LWS_CALLBACK_CLIENT_RECEIVE_PONG</h3>
633<blockquote>
634if you elected to see PONG packets,
635they appear with this callback reason. PONG
636packets only exist in 04+ protocol
637</blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000638<h3>LWS_CALLBACK_CLIENT_RECEIVE</h3>
639<blockquote>
640data has appeared from the server for the
641client connection, it can be found at *in and
642is len bytes long
Andy Green8f037e42010-12-19 22:13:26 +0000643</blockquote>
644<h3>LWS_CALLBACK_HTTP</h3>
645<blockquote>
646an http request has come from a client that is not
647asking to upgrade the connection to a websocket
648one. This is a chance to serve http content,
649for example, to send a script to the client
650which will then open the websockets connection.
Andy Green7619c472011-01-23 17:47:08 +0000651<tt><b>in</b></tt> points to the URI path requested and
Andy Green8f037e42010-12-19 22:13:26 +0000652<b>libwebsockets_serve_http_file</b> makes it very
653simple to send back a file to the client.
Andy Green24b588b2013-01-13 09:53:18 +0800654Normally after sending the file you are done
655with the http connection, since the rest of the
656activity will come by websockets from the script
657that was delivered by http, so you will want to
658return 1; to close and free up the connection.
659That's important because it uses a slot in the
660total number of client connections allowed set
661by MAX_CLIENTS.
Andy Green8f037e42010-12-19 22:13:26 +0000662</blockquote>
Andy Greend280b6e2013-01-15 13:40:23 +0800663<h3>LWS_CALLBACK_HTTP_FILE_COMPLETION</h3>
664<blockquote>
665a file requested to be send down
666http link has completed.
667</blockquote>
Andy Greene9739ed2011-03-07 21:40:59 +0000668<h3>LWS_CALLBACK_SERVER_WRITEABLE</h3>
Andy Green90c7cbc2011-01-27 06:26:52 +0000669<blockquote>
Andy Greene9739ed2011-03-07 21:40:59 +0000670If you call
Andy Green90c7cbc2011-01-27 06:26:52 +0000671<b>libwebsocket_callback_on_writable</b> on a connection, you will
Andy Greene9739ed2011-03-07 21:40:59 +0000672get one of these callbacks coming when the connection socket
673is able to accept another write packet without blocking.
674If it already was able to take another packet without blocking,
675you'll get this callback at the next call to the service loop
676function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE
677and servers get LWS_CALLBACK_SERVER_WRITEABLE.
Andy Green90c7cbc2011-01-27 06:26:52 +0000678</blockquote>
Andy Green07034092011-02-13 08:37:12 +0000679<h3>LWS_CALLBACK_FILTER_NETWORK_CONNECTION</h3>
680<blockquote>
681called when a client connects to
682the server at network level; the connection is accepted but then
683passed to this callback to decide whether to hang up immediately
684or not, based on the client IP. <tt><b>user</b></tt> contains the connection
685socket's descriptor. Return non-zero to terminate
686the connection before sending or receiving anything.
687Because this happens immediately after the network connection
688from the client, there's no websocket protocol selected yet so
689this callback is issued only to protocol 0.
690</blockquote>
Andy Greenc85619d2011-02-13 08:25:26 +0000691<h3>LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION</h3>
692<blockquote>
693called when the handshake has
694been received and parsed from the client, but the response is
695not sent yet. Return non-zero to disallow the connection.
Andy Green07034092011-02-13 08:37:12 +0000696<tt><b>user</b></tt> is a pointer to an array of struct lws_tokens, you can
697use the header enums lws_token_indexes from libwebsockets.h
698to check for and read the supported header presence and
699content before deciding to allow the handshake to proceed or
700to kill the connection.
Andy Green0894bda2011-02-19 09:09:11 +0000701</blockquote>
702<h3>LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS</h3>
703<blockquote>
Andy Green6901cb32011-02-21 08:06:47 +0000704if configured for
Andy Green0894bda2011-02-19 09:09:11 +0000705including OpenSSL support, this callback allows your user code
706to perform extra <b>SSL_CTX_load_verify_locations</b> or similar
707calls to direct OpenSSL where to find certificates the client
708can use to confirm the remote server identity. <tt><b>user</b></tt> is the
709OpenSSL SSL_CTX*
Andy Green6901cb32011-02-21 08:06:47 +0000710</blockquote>
711<h3>LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS</h3>
712<blockquote>
713if configured for
714including OpenSSL support, this callback allows your user code
715to load extra certifcates into the server which allow it to
716verify the validity of certificates returned by clients. <tt><b>user</b></tt>
717is the server's OpenSSL SSL_CTX*
718</blockquote>
719<h3>LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION</h3>
720<blockquote>
721if the
722libwebsockets context was created with the option
723LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this
724callback is generated during OpenSSL verification of the cert
725sent from the client. It is sent to protocol[0] callback as
726no protocol has been negotiated on the connection yet.
727Notice that the libwebsockets context and wsi are both NULL
728during this callback. See
729</blockquote>
730<h3>http</h3>
731<blockquote>
732//www.openssl.org/docs/ssl/SSL_CTX_set_verify.html
733to understand more detail about the OpenSSL callback that
734generates this libwebsockets callback and the meanings of the
735arguments passed. In this callback, <tt><b>user</b></tt> is the x509_ctx,
736<tt><b>in</b></tt> is the ssl pointer and <tt><b>len</b></tt> is preverify_ok
737Notice that this callback maintains libwebsocket return
738conventions, return 0 to mean the cert is OK or 1 to fail it.
739This also means that if you don't handle this callback then
740the default callback action of returning 0 allows the client
741certificates.
Andy Green385e7ad2011-03-01 21:06:02 +0000742</blockquote>
743<h3>LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER</h3>
744<blockquote>
745this callback happens
746when a client handshake is being compiled. <tt><b>user</b></tt> is NULL,
747<tt><b>in</b></tt> is a char **, it's pointing to a char * which holds the
748next location in the header buffer where you can add
749headers, and <tt><b>len</b></tt> is the remaining space in the header buffer,
750which is typically some hundreds of bytes. So, to add a canned
751cookie, your handler code might look similar to:
752<p>
753char **p = (char **)in;
754<p>
755if (len &lt; 100)
756return 1;
757<p>
758*p += sprintf(*p, "Cookie: a=b\x0d\x0a");
759<p>
760return 0;
761<p>
762Notice if you add anything, you just have to take care about
763the CRLF on the line you added. Obviously this callback is
764optional, if you don't handle it everything is fine.
765<p>
766Notice the callback is coming to protocols[0] all the time,
767because there is no specific protocol handshook yet.
Andy Greenc5114822011-03-06 10:29:35 +0000768</blockquote>
769<h3>LWS_CALLBACK_CONFIRM_EXTENSION_OKAY</h3>
770<blockquote>
771When the server handshake code
772sees that it does support a requested extension, before
773accepting the extension by additing to the list sent back to
774the client it gives this callback just to check that it's okay
775to use that extension. It calls back to the requested protocol
776and with <tt><b>in</b></tt> being the extension name, <tt><b>len</b></tt> is 0 and <tt><b>user</b></tt> is
777valid. Note though at this time the ESTABLISHED callback hasn't
778happened yet so if you initialize <tt><b>user</b></tt> content there, <tt><b>user</b></tt>
779content during this callback might not be useful for anything.
780Notice this callback comes to protocols[0].
Andy Greenc6517fa2011-03-06 13:15:29 +0000781</blockquote>
782<h3>LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED</h3>
783<blockquote>
784When a client
785connection is being prepared to start a handshake to a server,
786each supported extension is checked with protocols[0] callback
787with this reason, giving the user code a chance to suppress the
788claim to support that extension by returning non-zero. If
789unhandled, by default 0 will be returned and the extension
790support included in the header to the server. Notice this
791callback comes to protocols[0].
Andy Greenc85619d2011-02-13 08:25:26 +0000792<p>
793The next four reasons are optional and only need taking care of if you
794will be integrating libwebsockets sockets into an external polling
795array.
796</blockquote>
797<h3>LWS_CALLBACK_ADD_POLL_FD</h3>
798<blockquote>
799libwebsocket deals with its <b>poll</b> loop
800internally, but in the case you are integrating with another
801server you will need to have libwebsocket sockets share a
802polling array with the other server. This and the other
803POLL_FD related callbacks let you put your specialized
804poll array interface code in the callback for protocol 0, the
805first protocol you support, usually the HTTP protocol in the
806serving case. This callback happens when a socket needs to be
807</blockquote>
808<h3>added to the polling loop</h3>
809<blockquote>
810<tt><b>user</b></tt> contains the fd, and
811<tt><b>len</b></tt> is the events bitmap (like, POLLIN). If you are using the
812internal polling loop (the "service" callback), you can just
813ignore these callbacks.
814</blockquote>
815<h3>LWS_CALLBACK_DEL_POLL_FD</h3>
816<blockquote>
817This callback happens when a socket descriptor
818needs to be removed from an external polling array. <tt><b>user</b></tt> is
819the socket desricptor. If you are using the internal polling
820loop, you can just ignore it.
821</blockquote>
822<h3>LWS_CALLBACK_SET_MODE_POLL_FD</h3>
823<blockquote>
824This callback happens when libwebsockets
825wants to modify the events for the socket descriptor in <tt><b>user</b></tt>.
826The handler should OR <tt><b>len</b></tt> on to the events member of the pollfd
827struct for this socket descriptor. If you are using the
828internal polling loop, you can just ignore it.
829</blockquote>
830<h3>LWS_CALLBACK_CLEAR_MODE_POLL_FD</h3>
831<blockquote>
832This callback occurs when libwebsockets
833wants to modify the events for the socket descriptor in <tt><b>user</b></tt>.
834The handler should AND ~<tt><b>len</b></tt> on to the events member of the
835pollfd struct for this socket descriptor. If you are using the
836internal polling loop, you can just ignore it.
837</blockquote>
Andy Green8f037e42010-12-19 22:13:26 +0000838<hr>
Andy Green57b4e9a2011-03-06 13:14:46 +0000839<h2>extension_callback - Hooks to allow extensions to operate</h2>
Andy Green07b56e62011-10-03 19:30:22 +0800840<i>LWS_EXTERN int</i>
Andy Green57b4e9a2011-03-06 13:14:46 +0000841<b>extension_callback</b>
842(<i>struct libwebsocket_context *</i> <b>context</b>,
Andy Green46c2ea02011-03-22 09:04:01 +0000843<i>struct libwebsocket_extension *</i> <b>ext</b>,
Andy Green57b4e9a2011-03-06 13:14:46 +0000844<i>struct libwebsocket *</i> <b>wsi</b>,
David Brooks2c60d952012-04-20 12:19:01 +0800845<i>enum libwebsocket_extension_callback_reasons</i> <b>reason</b>,
Andy Green57b4e9a2011-03-06 13:14:46 +0000846<i>void *</i> <b>user</b>,
847<i>void *</i> <b>in</b>,
848<i>size_t</i> <b>len</b>)
849<h3>Arguments</h3>
850<dl>
851<dt><b>context</b>
852<dd>Websockets context
Andy Green46c2ea02011-03-22 09:04:01 +0000853<dt><b>ext</b>
854<dd>This extension
Andy Green57b4e9a2011-03-06 13:14:46 +0000855<dt><b>wsi</b>
856<dd>Opaque websocket instance pointer
857<dt><b>reason</b>
858<dd>The reason for the call
859<dt><b>user</b>
860<dd>Pointer to per-session user data allocated by library
861<dt><b>in</b>
862<dd>Pointer used for some callback reasons
863<dt><b>len</b>
864<dd>Length set for some callback reasons
865</dl>
866<h3>Description</h3>
867<blockquote>
868Each extension that is active on a particular connection receives
869callbacks during the connection lifetime to allow the extension to
870operate on websocket data and manage itself.
871<p>
872Libwebsockets takes care of allocating and freeing "user" memory for
873each active extension on each connection. That is what is pointed to
874by the <tt><b>user</b></tt> parameter.
875</blockquote>
876<h3>LWS_EXT_CALLBACK_CONSTRUCT</h3>
877<blockquote>
878called when the server has decided to
879select this extension from the list provided by the client,
880just before the server will send back the handshake accepting
881the connection with this extension active. This gives the
882extension a chance to initialize its connection context found
883in <tt><b>user</b></tt>.
884</blockquote>
Andy Green2366b1c2011-03-06 13:15:31 +0000885<h3>LWS_EXT_CALLBACK_CLIENT_CONSTRUCT</h3>
886<blockquote>
887same as LWS_EXT_CALLBACK_CONSTRUCT
888but called when client is instantiating this extension. Some
889extensions will work the same on client and server side and then
890you can just merge handlers for both CONSTRUCTS.
891</blockquote>
Andy Green57b4e9a2011-03-06 13:14:46 +0000892<h3>LWS_EXT_CALLBACK_DESTROY</h3>
893<blockquote>
894called when the connection the extension was
895being used on is about to be closed and deallocated. It's the
896last chance for the extension to deallocate anything it has
897allocated in the user data (pointed to by <tt><b>user</b></tt>) before the
Andy Green2366b1c2011-03-06 13:15:31 +0000898user data is deleted. This same callback is used whether you
899are in client or server instantiation context.
Andy Green57b4e9a2011-03-06 13:14:46 +0000900</blockquote>
901<h3>LWS_EXT_CALLBACK_PACKET_RX_PREPARSE</h3>
902<blockquote>
903when this extension was active on
904a connection, and a packet of data arrived at the connection,
905it is passed to this callback to give the extension a chance to
906change the data, eg, decompress it. <tt><b>user</b></tt> is pointing to the
907extension's private connection context data, <tt><b>in</b></tt> is pointing
908to an lws_tokens struct, it consists of a char * pointer called
909token, and an int called token_len. At entry, these are
910set to point to the received buffer and set to the content
911length. If the extension will grow the content, it should use
912a new buffer allocated in its private user context data and
913set the pointed-to lws_tokens members to point to its buffer.
914</blockquote>
915<h3>LWS_EXT_CALLBACK_PACKET_TX_PRESEND</h3>
916<blockquote>
917this works the same way as
918LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the
919extension a chance to change websocket data just before it will
920be sent out. Using the same lws_token pointer scheme in <tt><b>in</b></tt>,
921the extension can change the buffer and the length to be
922transmitted how it likes. Again if it wants to grow the
923buffer safely, it should copy the data into its own buffer and
924set the lws_tokens token pointer to it.
925</blockquote>
926<hr>
Andy Green4f3943a2010-11-12 10:44:16 +0000927<h2>struct libwebsocket_protocols - List of protocols and handlers server supports.</h2>
928<b>struct libwebsocket_protocols</b> {<br>
929&nbsp; &nbsp; <i>const char *</i> <b>name</b>;<br>
David Brooks2c60d952012-04-20 12:19:01 +0800930&nbsp; &nbsp; <i>callback_function *</i> <b>callback</b>;<br>
Andy Green4f3943a2010-11-12 10:44:16 +0000931&nbsp; &nbsp; <i>size_t</i> <b>per_session_data_size</b>;<br>
Andy Greenb45993c2010-12-18 15:13:50 +0000932&nbsp; &nbsp; <i>struct libwebsocket_context *</i> <b>owning_server</b>;<br>
Andy Greenb45993c2010-12-18 15:13:50 +0000933&nbsp; &nbsp; <i>int</i> <b>protocol_index</b>;<br>
Andy Green4f3943a2010-11-12 10:44:16 +0000934};<br>
935<h3>Members</h3>
936<dl>
937<dt><b>name</b>
938<dd>Protocol name that must match the one given in the client
939Javascript new WebSocket(url, 'protocol') name
940<dt><b>callback</b>
941<dd>The service callback used for this protocol. It allows the
942service action for an entire protocol to be encapsulated in
943the protocol-specific callback
944<dt><b>per_session_data_size</b>
945<dd>Each new connection using this protocol gets
946this much memory allocated on connection establishment and
947freed on connection takedown. A pointer to this per-connection
948allocation is passed into the callback in the 'user' parameter
Andy Greenb45993c2010-12-18 15:13:50 +0000949<dt><b>owning_server</b>
950<dd>the server init call fills in this opaque pointer when
951registering this protocol with the server.
Andy Greenb45993c2010-12-18 15:13:50 +0000952<dt><b>protocol_index</b>
953<dd>which protocol we are starting from zero
Andy Green4f3943a2010-11-12 10:44:16 +0000954</dl>
955<h3>Description</h3>
956<blockquote>
957This structure represents one protocol supported by the server. An
958array of these structures is passed to <b>libwebsocket_create_server</b>
959allows as many protocols as you like to be handled by one server.
960</blockquote>
961<hr>
Andy Greend6e09112011-03-05 16:12:15 +0000962<h2>struct libwebsocket_extension - An extension we know how to cope with</h2>
963<b>struct libwebsocket_extension</b> {<br>
964&nbsp; &nbsp; <i>const char *</i> <b>name</b>;<br>
David Brooks2c60d952012-04-20 12:19:01 +0800965&nbsp; &nbsp; <i>extension_callback_function *</i> <b>callback</b>;<br>
Andy Greend6e09112011-03-05 16:12:15 +0000966&nbsp; &nbsp; <i>size_t</i> <b>per_session_data_size</b>;<br>
Andy Greenaa6fc442012-04-12 13:26:49 +0800967&nbsp; &nbsp; <i>void *</i> <b>per_context_private_data</b>;<br>
Andy Greend6e09112011-03-05 16:12:15 +0000968};<br>
969<h3>Members</h3>
970<dl>
971<dt><b>name</b>
972<dd>Formal extension name, eg, "deflate-stream"
973<dt><b>callback</b>
974<dd>Service callback
975<dt><b>per_session_data_size</b>
976<dd>Libwebsockets will auto-malloc this much
977memory for the use of the extension, a pointer
978to it comes in the <tt><b>user</b></tt> callback parameter
Andy Greenaa6fc442012-04-12 13:26:49 +0800979<dt><b>per_context_private_data</b>
980<dd>Optional storage for this externsion that
981is per-context, so it can track stuff across
982all sessions, etc, if it wants
Andy Greend6e09112011-03-05 16:12:15 +0000983</dl>
984<hr>