blob: 9e5f27ecfa18667a73c945c723617bbdaf5a1217 [file] [log] [blame]
Andy Green9f990342011-02-12 11:57:45 +00001<h2>libwebsocket_service_fd - Service polled socket with something waiting</h2>
2<i>int</i>
3<b>libwebsocket_service_fd</b>
4(<i>struct libwebsocket_context *</i> <b>this</b>,
5<i>struct pollfd *</i> <b>pollfd</b>)
6<h3>Arguments</h3>
7<dl>
8<dt><b>this</b>
9<dd>Websocket context
10<dt><b>pollfd</b>
11<dd>The pollfd entry describing the socket fd and which events
12happened.
13</dl>
14<h3>Description</h3>
15<blockquote>
16This function closes any active connections and then frees the
17context. After calling this, any further use of the context is
18undefined.
19</blockquote>
20<hr>
Andy Green6964bb52011-01-23 16:50:33 +000021<h2>libwebsocket_context_destroy - Destroy the websocket context</h2>
22<i>void</i>
23<b>libwebsocket_context_destroy</b>
24(<i>struct libwebsocket_context *</i> <b>this</b>)
25<h3>Arguments</h3>
26<dl>
27<dt><b>this</b>
28<dd>Websocket context
29</dl>
30<h3>Description</h3>
31<blockquote>
32This function closes any active connections and then frees the
33context. After calling this, any further use of the context is
34undefined.
35</blockquote>
36<hr>
37<h2>libwebsocket_service - Service any pending websocket activity</h2>
38<i>int</i>
39<b>libwebsocket_service</b>
40(<i>struct libwebsocket_context *</i> <b>this</b>,
41<i>int</i> <b>timeout_ms</b>)
42<h3>Arguments</h3>
43<dl>
44<dt><b>this</b>
45<dd>Websocket context
46<dt><b>timeout_ms</b>
47<dd>Timeout for poll; 0 means return immediately if nothing needed
48service otherwise block and service immediately, returning
49after the timeout if nothing needed service.
50</dl>
51<h3>Description</h3>
52<blockquote>
53This function deals with any pending websocket traffic, for three
54kinds of event. It handles these events on both server and client
55types of connection the same.
56<p>
571) Accept new connections to our context's server
58<p>
592) Perform pending broadcast writes initiated from other forked
60processes (effectively serializing asynchronous broadcasts)
61<p>
623) Call the receive callback for incoming frame data received by
63server or client connections.
64<p>
65You need to call this service function periodically to all the above
66functions to happen; if your application is single-threaded you can
67just call it in your main event loop.
68<p>
69Alternatively you can fork a new process that asynchronously handles
70calling this service in a loop. In that case you are happy if this
71call blocks your thread until it needs to take care of something and
72would call it with a large nonzero timeout. Your loop then takes no
73CPU while there is nothing happening.
74<p>
75If you are calling it in a single-threaded app, you don't want it to
76wait around blocking other things in your loop from happening, so you
77would call it with a timeout_ms of 0, so it returns immediately if
78nothing is pending, or as soon as it services whatever was pending.
79</blockquote>
80<hr>
Andy Green90c7cbc2011-01-27 06:26:52 +000081<h2>libwebsocket_callback_on_writable - Request a callback when this socket becomes able to be written to without blocking</h2>
82<i>int</i>
83<b>libwebsocket_callback_on_writable</b>
84(<i>struct libwebsocket *</i> <b>wsi</b>)
85<h3>Arguments</h3>
86<dl>
87<dt><b>wsi</b>
88<dd>Websocket connection instance to get callback for
89</dl>
Andy Green0d338332011-02-12 11:57:43 +000090<h3>Description</h3>
91<blockquote>
92<p>
93This only works for internal <b>poll</b> management, (ie, calling the libwebsocket
94service loop, you will have to make your own arrangements if your <b>poll</b>
95loop is managed externally.
96</blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +000097<hr>
98<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>
99<i>int</i>
100<b>libwebsocket_callback_on_writable_all_protocol</b>
101(<i>const struct libwebsocket_protocols *</i> <b>protocol</b>)
102<h3>Arguments</h3>
103<dl>
104<dt><b>protocol</b>
105<dd>Protocol whose connections will get callbacks
106</dl>
Andy Green0d338332011-02-12 11:57:43 +0000107<h3>Description</h3>
108<blockquote>
109<p>
110This only works for internal <b>poll</b> management, (ie, calling the libwebsocket
111service loop, you will have to make your own arrangements if your <b>poll</b>
112loop is managed externally.
113</blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000114<hr>
Andy Greena6cbece2011-01-27 20:06:03 +0000115<h2>libwebsocket_get_socket_fd - returns the socket file descriptor</h2>
116<i>int</i>
117<b>libwebsocket_get_socket_fd</b>
118(<i>struct libwebsocket *</i> <b>wsi</b>)
119<h3>Arguments</h3>
120<dl>
121<dt><b>wsi</b>
122<dd>Websocket connection instance
123</dl>
124<h3>Description</h3>
125<blockquote>
126<p>
127You will not need this unless you are doing something special
128</blockquote>
129<hr>
Andy Green90c7cbc2011-01-27 06:26:52 +0000130<h2>libwebsocket_rx_flow_control - Enable and disable socket servicing for receieved packets.</h2>
131<i>int</i>
132<b>libwebsocket_rx_flow_control</b>
133(<i>struct libwebsocket *</i> <b>wsi</b>,
134<i>int</i> <b>enable</b>)
135<h3>Arguments</h3>
136<dl>
137<dt><b>wsi</b>
138<dd>Websocket connection instance to get callback for
139<dt><b>enable</b>
140<dd>0 = disable read servicing for this connection, 1 = enable
141</dl>
142<h3>Description</h3>
143<blockquote>
144<p>
145If the output side of a server process becomes choked, this allows flow
146control for the input side.
Andy Green0d338332011-02-12 11:57:43 +0000147<p>
148This only works for internal <b>poll</b> management, (ie, calling the libwebsocket
149service loop, you will have to make your own arrangements if your <b>poll</b>
150loop is managed externally.
Andy Green90c7cbc2011-01-27 06:26:52 +0000151</blockquote>
152<hr>
Andy Green2ac5a6f2011-01-28 10:00:18 +0000153<h2>libwebsocket_canonical_hostname - returns this host's hostname</h2>
154<i>const char *</i>
155<b>libwebsocket_canonical_hostname</b>
156(<i>struct libwebsocket_context *</i> <b>this</b>)
157<h3>Arguments</h3>
158<dl>
159<dt><b>this</b>
160<dd>Websocket context
161</dl>
162<h3>Description</h3>
163<blockquote>
164<p>
165This is typically used by client code to fill in the host parameter
166when making a client connection. You can only call it after the context
167has been created.
168</blockquote>
169<hr>
Andy Green4739e5c2011-01-22 12:51:57 +0000170<h2>libwebsocket_create_context - Create the websocket handler</h2>
Andy Greene92cd172011-01-19 13:11:55 +0000171<i>struct libwebsocket_context *</i>
Andy Green4739e5c2011-01-22 12:51:57 +0000172<b>libwebsocket_create_context</b>
Andy Green62a12932010-11-03 11:19:23 +0000173(<i>int</i> <b>port</b>,
Andy Greenb45993c2010-12-18 15:13:50 +0000174<i>struct libwebsocket_protocols *</i> <b>protocols</b>,
Andy Green3faa9c72010-11-08 17:03:03 +0000175<i>const char *</i> <b>ssl_cert_filepath</b>,
176<i>const char *</i> <b>ssl_private_key_filepath</b>,
177<i>int</i> <b>gid</b>,
Andy Green8014b292011-01-30 20:57:25 +0000178<i>int</i> <b>uid</b>,
179<i>unsigned int</i> <b>options</b>)
Andy Green62a12932010-11-03 11:19:23 +0000180<h3>Arguments</h3>
181<dl>
182<dt><b>port</b>
Andy Green4739e5c2011-01-22 12:51:57 +0000183<dd>Port to listen on... you can use 0 to suppress listening on
184any port, that's what you want if you are not running a
185websocket server at all but just using it as a client
Andy Green4f3943a2010-11-12 10:44:16 +0000186<dt><b>protocols</b>
187<dd>Array of structures listing supported protocols and a protocol-
188specific callback for each one. The list is ended with an
189entry that has a NULL callback pointer.
Andy Greenb45993c2010-12-18 15:13:50 +0000190It's not const because we write the owning_server member
Andy Green3faa9c72010-11-08 17:03:03 +0000191<dt><b>ssl_cert_filepath</b>
192<dd>If libwebsockets was compiled to use ssl, and you want
193to listen using SSL, set to the filepath to fetch the
194server cert from, otherwise NULL for unencrypted
195<dt><b>ssl_private_key_filepath</b>
196<dd>filepath to private key if wanting SSL mode,
197else ignored
198<dt><b>gid</b>
199<dd>group id to change to after setting listen socket, or -1.
200<dt><b>uid</b>
201<dd>user id to change to after setting listen socket, or -1.
Andy Greenbfb051f2011-02-09 08:49:14 +0000202<dt><b>options</b>
203<dd>0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
Andy Green62a12932010-11-03 11:19:23 +0000204</dl>
205<h3>Description</h3>
206<blockquote>
Andy Green47943ae2010-11-12 11:15:49 +0000207This function creates the listening socket and takes care
Andy Green62a12932010-11-03 11:19:23 +0000208of all initialization in one step.
209<p>
Andy Greene92cd172011-01-19 13:11:55 +0000210After initialization, it returns a struct libwebsocket_context * that
211represents this server. After calling, user code needs to take care
212of calling <b>libwebsocket_service</b> with the context pointer to get the
213server's sockets serviced. This can be done in the same process context
214or a forked process, or another thread,
Andy Green47943ae2010-11-12 11:15:49 +0000215<p>
216The protocol callback functions are called for a handful of events
217including http requests coming in, websocket connections becoming
Andy Green62a12932010-11-03 11:19:23 +0000218established, and data arriving; it's also called periodically to allow
219async transmission.
220<p>
Andy Green47943ae2010-11-12 11:15:49 +0000221HTTP requests are sent always to the FIRST protocol in <tt><b>protocol</b></tt>, since
222at that time websocket protocol has not been negotiated. Other
223protocols after the first one never see any HTTP callack activity.
224<p>
Andy Green62a12932010-11-03 11:19:23 +0000225The server created is a simple http server by default; part of the
226websocket standard is upgrading this http connection to a websocket one.
227<p>
228This allows the same server to provide files like scripts and favicon /
229images or whatever over http and dynamic data over websockets all in
230one place; they're all handled in the user callback.
231</blockquote>
232<hr>
Andy Greene92cd172011-01-19 13:11:55 +0000233<h2>libwebsockets_fork_service_loop - Optional helper function forks off a process for the websocket server loop. You don't have to use this but if not, you have to make sure you are calling libwebsocket_service periodically to service the websocket traffic</h2>
234<i>int</i>
235<b>libwebsockets_fork_service_loop</b>
236(<i>struct libwebsocket_context *</i> <b>this</b>)
237<h3>Arguments</h3>
238<dl>
239<dt><b>this</b>
240<dd>server context returned by creation function
241</dl>
242<hr>
Andy Greenb45993c2010-12-18 15:13:50 +0000243<h2>libwebsockets_get_protocol - Returns a protocol pointer from a websocket connection.</h2>
244<i>const struct libwebsocket_protocols *</i>
245<b>libwebsockets_get_protocol</b>
246(<i>struct libwebsocket *</i> <b>wsi</b>)
247<h3>Arguments</h3>
248<dl>
249<dt><b>wsi</b>
250<dd>pointer to struct websocket you want to know the protocol of
251</dl>
252<h3>Description</h3>
253<blockquote>
254<p>
255This is useful to get the protocol to broadcast back to from inside
256the callback.
257</blockquote>
258<hr>
Andy Greene92cd172011-01-19 13:11:55 +0000259<h2>libwebsockets_broadcast - Sends a buffer to the callback for all active connections of the given protocol.</h2>
Andy Greenb45993c2010-12-18 15:13:50 +0000260<i>int</i>
261<b>libwebsockets_broadcast</b>
262(<i>const struct libwebsocket_protocols *</i> <b>protocol</b>,
263<i>unsigned char *</i> <b>buf</b>,
264<i>size_t</i> <b>len</b>)
265<h3>Arguments</h3>
266<dl>
267<dt><b>protocol</b>
268<dd>pointer to the protocol you will broadcast to all members of
269<dt><b>buf</b>
270<dd>buffer containing the data to be broadcase. NOTE: this has to be
271allocated with LWS_SEND_BUFFER_PRE_PADDING valid bytes before
272the pointer and LWS_SEND_BUFFER_POST_PADDING afterwards in the
273case you are calling this function from callback context.
274<dt><b>len</b>
275<dd>length of payload data in buf, starting from buf.
276</dl>
277<h3>Description</h3>
278<blockquote>
279This function allows bulk sending of a packet to every connection using
280the given protocol. It does not send the data directly; instead it calls
281the callback with a reason type of LWS_CALLBACK_BROADCAST. If the callback
282wants to actually send the data for that connection, the callback itself
283should call <b>libwebsocket_write</b>.
284<p>
285<b>libwebsockets_broadcast</b> can be called from another fork context without
286having to take any care about data visibility between the processes, it'll
287"just work".
288</blockquote>
289<hr>
Andy Green62a12932010-11-03 11:19:23 +0000290<h2>libwebsocket_write - Apply protocol then write data to client</h2>
291<i>int</i>
292<b>libwebsocket_write</b>
293(<i>struct libwebsocket *</i> <b>wsi</b>,
294<i>unsigned char *</i> <b>buf</b>,
295<i>size_t</i> <b>len</b>,
296<i>enum libwebsocket_write_protocol</i> <b>protocol</b>)
297<h3>Arguments</h3>
298<dl>
299<dt><b>wsi</b>
300<dd>Websocket instance (available from user callback)
301<dt><b>buf</b>
302<dd>The data to send. For data being sent on a websocket
303connection (ie, not default http), this buffer MUST have
304LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE the pointer
305and an additional LWS_SEND_BUFFER_POST_PADDING bytes valid
306in the buffer after (buf + len). This is so the protocol
307header and trailer data can be added in-situ.
308<dt><b>len</b>
309<dd>Count of the data bytes in the payload starting from buf
310<dt><b>protocol</b>
311<dd>Use LWS_WRITE_HTTP to reply to an http connection, and one
312of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate
313data on a websockets connection. Remember to allow the extra
314bytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT
315are used.
316</dl>
317<h3>Description</h3>
318<blockquote>
319This function provides the way to issue data back to the client
320for both http and websocket protocols.
321<p>
322In the case of sending using websocket protocol, be sure to allocate
323valid storage before and after buf as explained above. This scheme
324allows maximum efficiency of sending data and protocol in a single
325packet while not burdening the user code with any protocol knowledge.
326</blockquote>
327<hr>
328<h2>libwebsockets_serve_http_file - Send a file back to the client using http</h2>
329<i>int</i>
330<b>libwebsockets_serve_http_file</b>
331(<i>struct libwebsocket *</i> <b>wsi</b>,
332<i>const char *</i> <b>file</b>,
333<i>const char *</i> <b>content_type</b>)
334<h3>Arguments</h3>
335<dl>
336<dt><b>wsi</b>
337<dd>Websocket instance (available from user callback)
338<dt><b>file</b>
339<dd>The file to issue over http
340<dt><b>content_type</b>
341<dd>The http content type, eg, text/html
342</dl>
343<h3>Description</h3>
344<blockquote>
345This function is intended to be called from the callback in response
346to http requests from the client. It allows the callback to issue
347local files down the http link in a single step.
348</blockquote>
349<hr>
Andy Green38e57bb2011-01-19 12:20:27 +0000350<h2>libwebsockets_remaining_packet_payload - Bytes to come before "overall" rx packet is complete</h2>
351<i>size_t</i>
352<b>libwebsockets_remaining_packet_payload</b>
353(<i>struct libwebsocket *</i> <b>wsi</b>)
354<h3>Arguments</h3>
355<dl>
356<dt><b>wsi</b>
357<dd>Websocket instance (available from user callback)
358</dl>
359<h3>Description</h3>
360<blockquote>
361This function is intended to be called from the callback if the
362user code is interested in "complete packets" from the client.
363libwebsockets just passes through payload as it comes and issues a buffer
364additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE
365callback handler can use this API to find out if the buffer it has just
366been given is the last piece of a "complete packet" from the client --
367when that is the case <b>libwebsockets_remaining_packet_payload</b> will return
3680.
369<p>
370Many protocols won't care becuse their packets are always small.
371</blockquote>
372<hr>
Andy Green90c7cbc2011-01-27 06:26:52 +0000373<h2>libwebsocket_client_connect - Connect to another websocket server</h2>
374<i>struct libwebsocket *</i>
375<b>libwebsocket_client_connect</b>
376(<i>struct libwebsocket_context *</i> <b>this</b>,
377<i>const char *</i> <b>address</b>,
378<i>int</i> <b>port</b>,
379<i>int</i> <b>ssl_connection</b>,
380<i>const char *</i> <b>path</b>,
381<i>const char *</i> <b>host</b>,
382<i>const char *</i> <b>origin</b>,
Andy Greenbfb051f2011-02-09 08:49:14 +0000383<i>const char *</i> <b>protocol</b>,
384<i>int</i> <b>ietf_version_or_minus_one</b>)
Andy Green90c7cbc2011-01-27 06:26:52 +0000385<h3>Arguments</h3>
386<dl>
387<dt><b>this</b>
388<dd>Websocket context
389<dt><b>address</b>
390<dd>Remote server address, eg, "myserver.com"
391<dt><b>port</b>
392<dd>Port to connect to on the remote server, eg, 80
393<dt><b>ssl_connection</b>
394<dd>0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
395signed certs
396<dt><b>path</b>
397<dd>Websocket path on server
398<dt><b>host</b>
399<dd>Hostname on server
400<dt><b>origin</b>
401<dd>Socket origin name
402<dt><b>protocol</b>
403<dd>Comma-separated list of protocols being asked for from
404the server, or just one. The server will pick the one it
405likes best.
Andy Greenbfb051f2011-02-09 08:49:14 +0000406<dt><b>ietf_version_or_minus_one</b>
407<dd>-1 to ask to connect using the default, latest
408protocol supported, or the specific protocol ordinal
Andy Green90c7cbc2011-01-27 06:26:52 +0000409</dl>
410<h3>Description</h3>
411<blockquote>
412This function creates a connection to a remote server
413</blockquote>
414<hr>
Andy Green8f037e42010-12-19 22:13:26 +0000415<h2>callback - User server actions</h2>
416<i>int</i>
417<b>callback</b>
418(<i>struct libwebsocket *</i> <b>wsi</b>,
419<i>enum libwebsocket_callback_reasons</i> <b>reason</b>,
420<i>void *</i> <b>user</b>,
421<i>void *</i> <b>in</b>,
422<i>size_t</i> <b>len</b>)
423<h3>Arguments</h3>
424<dl>
425<dt><b>wsi</b>
426<dd>Opaque websocket instance pointer
427<dt><b>reason</b>
428<dd>The reason for the call
429<dt><b>user</b>
430<dd>Pointer to per-session user data allocated by library
431<dt><b>in</b>
432<dd>Pointer used for some callback reasons
433<dt><b>len</b>
434<dd>Length set for some callback reasons
435</dl>
436<h3>Description</h3>
437<blockquote>
438This callback is the way the user controls what is served. All the
439protocol detail is hidden and handled by the library.
440<p>
441For each connection / session there is user data allocated that is
442pointed to by "user". You set the size of this user data area when
443the library is initialized with libwebsocket_create_server.
444<p>
445You get an opportunity to initialize user data when called back with
446LWS_CALLBACK_ESTABLISHED reason.
447</blockquote>
448<h3>LWS_CALLBACK_ESTABLISHED</h3>
449<blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000450after the server completes a handshake with
451an incoming client
452</blockquote>
453<h3>LWS_CALLBACK_CLIENT_ESTABLISHED</h3>
454<blockquote>
455after your client connection completed
456a handshake with the remote server
Andy Green8f037e42010-12-19 22:13:26 +0000457</blockquote>
458<h3>LWS_CALLBACK_CLOSED</h3>
459<blockquote>
460when the websocket session ends
461</blockquote>
462<h3>LWS_CALLBACK_BROADCAST</h3>
463<blockquote>
464signal to send to client (you would use
465<b>libwebsocket_write</b> taking care about the
466special buffer requirements
467</blockquote>
468<h3>LWS_CALLBACK_RECEIVE</h3>
469<blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000470data has appeared for this server endpoint from a
471remote client, it can be found at *in and is
472len bytes long
473</blockquote>
Andy Greena6cbece2011-01-27 20:06:03 +0000474<h3>LWS_CALLBACK_CLIENT_RECEIVE_PONG</h3>
475<blockquote>
476if you elected to see PONG packets,
477they appear with this callback reason. PONG
478packets only exist in 04+ protocol
479</blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000480<h3>LWS_CALLBACK_CLIENT_RECEIVE</h3>
481<blockquote>
482data has appeared from the server for the
483client connection, it can be found at *in and
484is len bytes long
Andy Green8f037e42010-12-19 22:13:26 +0000485</blockquote>
486<h3>LWS_CALLBACK_HTTP</h3>
487<blockquote>
488an http request has come from a client that is not
489asking to upgrade the connection to a websocket
490one. This is a chance to serve http content,
491for example, to send a script to the client
492which will then open the websockets connection.
Andy Green7619c472011-01-23 17:47:08 +0000493<tt><b>in</b></tt> points to the URI path requested and
Andy Green8f037e42010-12-19 22:13:26 +0000494<b>libwebsockets_serve_http_file</b> makes it very
495simple to send back a file to the client.
496</blockquote>
Andy Green90c7cbc2011-01-27 06:26:52 +0000497<h3>LWS_CALLBACK_CLIENT_WRITEABLE</h3>
498<blockquote>
499if you call
500<b>libwebsocket_callback_on_writable</b> on a connection, you will
501get this callback coming when the connection socket is able to
502accept another write packet without blocking. If it already
503was able to take another packet without blocking, you'll get
504this callback at the next call to the service loop function.
505</blockquote>
Andy Green8f037e42010-12-19 22:13:26 +0000506<hr>
Andy Green4f3943a2010-11-12 10:44:16 +0000507<h2>struct libwebsocket_protocols - List of protocols and handlers server supports.</h2>
508<b>struct libwebsocket_protocols</b> {<br>
509&nbsp; &nbsp; <i>const char *</i> <b>name</b>;<br>
Andy Greene77ddd82010-11-13 10:03:47 +0000510&nbsp; &nbsp; <i>int (*</i><b>callback</b>) <i>(struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len)</i>;<br>
Andy Green4f3943a2010-11-12 10:44:16 +0000511&nbsp; &nbsp; <i>size_t</i> <b>per_session_data_size</b>;<br>
Andy Greenb45993c2010-12-18 15:13:50 +0000512&nbsp; &nbsp; <i>struct libwebsocket_context *</i> <b>owning_server</b>;<br>
513&nbsp; &nbsp; <i>int</i> <b>broadcast_socket_port</b>;<br>
514&nbsp; &nbsp; <i>int</i> <b>broadcast_socket_user_fd</b>;<br>
515&nbsp; &nbsp; <i>int</i> <b>protocol_index</b>;<br>
Andy Green4f3943a2010-11-12 10:44:16 +0000516};<br>
517<h3>Members</h3>
518<dl>
519<dt><b>name</b>
520<dd>Protocol name that must match the one given in the client
521Javascript new WebSocket(url, 'protocol') name
522<dt><b>callback</b>
523<dd>The service callback used for this protocol. It allows the
524service action for an entire protocol to be encapsulated in
525the protocol-specific callback
526<dt><b>per_session_data_size</b>
527<dd>Each new connection using this protocol gets
528this much memory allocated on connection establishment and
529freed on connection takedown. A pointer to this per-connection
530allocation is passed into the callback in the 'user' parameter
Andy Greenb45993c2010-12-18 15:13:50 +0000531<dt><b>owning_server</b>
532<dd>the server init call fills in this opaque pointer when
533registering this protocol with the server.
534<dt><b>broadcast_socket_port</b>
535<dd>the server init call fills this in with the
536localhost port number used to forward broadcasts for this
537protocol
538<dt><b>broadcast_socket_user_fd</b>
539<dd>the server init call fills this in ... the <b>main</b>
540process context can write to this socket to perform broadcasts
541(use the <b>libwebsockets_broadcast</b> api to do this instead,
542it works from any process context)
543<dt><b>protocol_index</b>
544<dd>which protocol we are starting from zero
Andy Green4f3943a2010-11-12 10:44:16 +0000545</dl>
546<h3>Description</h3>
547<blockquote>
548This structure represents one protocol supported by the server. An
549array of these structures is passed to <b>libwebsocket_create_server</b>
550allows as many protocols as you like to be handled by one server.
551</blockquote>
552<hr>