introduce this param in callback fix server close on client socket
[profile/ivi/libwebsockets.git] / libwebsockets-api-doc.html
1 <h2>libwebsockets_hangup_on_client - Server calls to terminate client connection</h2>
2 <i>void</i>
3 <b>libwebsockets_hangup_on_client</b>
4 (<i>struct libwebsocket_context *</i> <b>this</b>,
5 <i>int</i> <b>fd</b>)
6 <h3>Arguments</h3>
7 <dl>
8 <dt><b>this</b>
9 <dd>libwebsockets context
10 <dt><b>fd</b>
11 <dd>Connection socket descriptor
12 </dl>
13 <hr>
14 <h2>libwebsockets_get_peer_addresses - Get client address information</h2>
15 <i>void</i>
16 <b>libwebsockets_get_peer_addresses</b>
17 (<i>int</i> <b>fd</b>,
18 <i>char *</i> <b>name</b>,
19 <i>int</i> <b>name_len</b>,
20 <i>char *</i> <b>rip</b>,
21 <i>int</i> <b>rip_len</b>)
22 <h3>Arguments</h3>
23 <dl>
24 <dt><b>fd</b>
25 <dd>Connection socket descriptor
26 <dt><b>name</b>
27 <dd>Buffer to take client address name
28 <dt><b>name_len</b>
29 <dd>Length of client address name buffer
30 <dt><b>rip</b>
31 <dd>Buffer to take client address IP qotted quad
32 <dt><b>rip_len</b>
33 <dd>Length of client address IP buffer
34 </dl>
35 <h3>Description</h3>
36 <blockquote>
37 This function fills in <tt><b>name</b></tt> and <tt><b>rip</b></tt> with the name and IP of
38 the client connected with socket descriptor <tt><b>fd</b></tt>.  Names may be
39 truncated if there is not enough room.  If either cannot be
40 determined, they will be returned as valid zero-length strings.
41 </blockquote>
42 <hr>
43 <h2>libwebsocket_service_fd - Service polled socket with something waiting</h2>
44 <i>int</i>
45 <b>libwebsocket_service_fd</b>
46 (<i>struct libwebsocket_context *</i> <b>this</b>,
47 <i>struct pollfd *</i> <b>pollfd</b>)
48 <h3>Arguments</h3>
49 <dl>
50 <dt><b>this</b>
51 <dd>Websocket context
52 <dt><b>pollfd</b>
53 <dd>The pollfd entry describing the socket fd and which events
54 happened.
55 </dl>
56 <h3>Description</h3>
57 <blockquote>
58 This function closes any active connections and then frees the
59 context.  After calling this, any further use of the context is
60 undefined.
61 </blockquote>
62 <hr>
63 <h2>libwebsocket_context_destroy - Destroy the websocket context</h2>
64 <i>void</i>
65 <b>libwebsocket_context_destroy</b>
66 (<i>struct libwebsocket_context *</i> <b>this</b>)
67 <h3>Arguments</h3>
68 <dl>
69 <dt><b>this</b>
70 <dd>Websocket context
71 </dl>
72 <h3>Description</h3>
73 <blockquote>
74 This function closes any active connections and then frees the
75 context.  After calling this, any further use of the context is
76 undefined.
77 </blockquote>
78 <hr>
79 <h2>libwebsocket_service - Service any pending websocket activity</h2>
80 <i>int</i>
81 <b>libwebsocket_service</b>
82 (<i>struct libwebsocket_context *</i> <b>this</b>,
83 <i>int</i> <b>timeout_ms</b>)
84 <h3>Arguments</h3>
85 <dl>
86 <dt><b>this</b>
87 <dd>Websocket context
88 <dt><b>timeout_ms</b>
89 <dd>Timeout for poll; 0 means return immediately if nothing needed
90 service otherwise block and service immediately, returning
91 after the timeout if nothing needed service.
92 </dl>
93 <h3>Description</h3>
94 <blockquote>
95 This function deals with any pending websocket traffic, for three
96 kinds of event.  It handles these events on both server and client
97 types of connection the same.
98 <p>
99 1) Accept new connections to our context's server
100 <p>
101 2) Perform pending broadcast writes initiated from other forked
102 processes (effectively serializing asynchronous broadcasts)
103 <p>
104 3) Call the receive callback for incoming frame data received by
105 server or client connections.
106 <p>
107 You need to call this service function periodically to all the above
108 functions to happen; if your application is single-threaded you can
109 just call it in your main event loop.
110 <p>
111 Alternatively you can fork a new process that asynchronously handles
112 calling this service in a loop.  In that case you are happy if this
113 call blocks your thread until it needs to take care of something and
114 would call it with a large nonzero timeout.  Your loop then takes no
115 CPU while there is nothing happening.
116 <p>
117 If you are calling it in a single-threaded app, you don't want it to
118 wait around blocking other things in your loop from happening, so you
119 would call it with a timeout_ms of 0, so it returns immediately if
120 nothing is pending, or as soon as it services whatever was pending.
121 </blockquote>
122 <hr>
123 <h2>libwebsocket_callback_on_writable - Request a callback when this socket becomes able to be written to without blocking *</h2>
124 <i>int</i>
125 <b>libwebsocket_callback_on_writable</b>
126 (<i>struct libwebsocket_context *</i> <b>this</b>,
127 <i>struct libwebsocket *</i> <b>wsi</b>)
128 <h3>Arguments</h3>
129 <dl>
130 <dt><b>wsi</b>
131 <dd>Websocket connection instance to get callback for
132 </dl>
133 <hr>
134 <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>
135 <i>int</i>
136 <b>libwebsocket_callback_on_writable_all_protocol</b>
137 (<i>const struct libwebsocket_protocols *</i> <b>protocol</b>)
138 <h3>Arguments</h3>
139 <dl>
140 <dt><b>protocol</b>
141 <dd>Protocol whose connections will get callbacks
142 </dl>
143 <hr>
144 <h2>libwebsocket_get_socket_fd - returns the socket file descriptor</h2>
145 <i>int</i>
146 <b>libwebsocket_get_socket_fd</b>
147 (<i>struct libwebsocket *</i> <b>wsi</b>)
148 <h3>Arguments</h3>
149 <dl>
150 <dt><b>wsi</b>
151 <dd>Websocket connection instance
152 </dl>
153 <h3>Description</h3>
154 <blockquote>
155 <p>
156 You will not need this unless you are doing something special
157 </blockquote>
158 <hr>
159 <h2>libwebsocket_rx_flow_control - Enable and disable socket servicing for receieved packets.</h2>
160 <i>int</i>
161 <b>libwebsocket_rx_flow_control</b>
162 (<i>struct libwebsocket *</i> <b>wsi</b>,
163 <i>int</i> <b>enable</b>)
164 <h3>Arguments</h3>
165 <dl>
166 <dt><b>wsi</b>
167 <dd>Websocket connection instance to get callback for
168 <dt><b>enable</b>
169 <dd>0 = disable read servicing for this connection, 1 = enable
170 </dl>
171 <h3>Description</h3>
172 <blockquote>
173 <p>
174 If the output side of a server process becomes choked, this allows flow
175 control for the input side.
176 </blockquote>
177 <hr>
178 <h2>libwebsocket_canonical_hostname - returns this host's hostname</h2>
179 <i>const char *</i>
180 <b>libwebsocket_canonical_hostname</b>
181 (<i>struct libwebsocket_context *</i> <b>this</b>)
182 <h3>Arguments</h3>
183 <dl>
184 <dt><b>this</b>
185 <dd>Websocket context
186 </dl>
187 <h3>Description</h3>
188 <blockquote>
189 <p>
190 This is typically used by client code to fill in the host parameter
191 when making a client connection.  You can only call it after the context
192 has been created.
193 </blockquote>
194 <hr>
195 <h2>libwebsocket_create_context - Create the websocket handler</h2>
196 <i>struct libwebsocket_context *</i>
197 <b>libwebsocket_create_context</b>
198 (<i>int</i> <b>port</b>,
199 <i>struct libwebsocket_protocols *</i> <b>protocols</b>,
200 <i>const char *</i> <b>ssl_cert_filepath</b>,
201 <i>const char *</i> <b>ssl_private_key_filepath</b>,
202 <i>int</i> <b>gid</b>,
203 <i>int</i> <b>uid</b>,
204 <i>unsigned int</i> <b>options</b>)
205 <h3>Arguments</h3>
206 <dl>
207 <dt><b>port</b>
208 <dd>Port to listen on... you can use 0 to suppress listening on
209 any port, that's what you want if you are not running a
210 websocket server at all but just using it as a client
211 <dt><b>protocols</b>
212 <dd>Array of structures listing supported protocols and a protocol-
213 specific callback for each one.  The list is ended with an
214 entry that has a NULL callback pointer.
215 It's not const because we write the owning_server member
216 <dt><b>ssl_cert_filepath</b>
217 <dd>If libwebsockets was compiled to use ssl, and you want
218 to listen using SSL, set to the filepath to fetch the
219 server cert from, otherwise NULL for unencrypted
220 <dt><b>ssl_private_key_filepath</b>
221 <dd>filepath to private key if wanting SSL mode,
222 else ignored
223 <dt><b>gid</b>
224 <dd>group id to change to after setting listen socket, or -1.
225 <dt><b>uid</b>
226 <dd>user id to change to after setting listen socket, or -1.
227 <dt><b>options</b>
228 <dd>0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
229 </dl>
230 <h3>Description</h3>
231 <blockquote>
232 This function creates the listening socket and takes care
233 of all initialization in one step.
234 <p>
235 After initialization, it returns a struct libwebsocket_context * that
236 represents this server.  After calling, user code needs to take care
237 of calling <b>libwebsocket_service</b> with the context pointer to get the
238 server's sockets serviced.  This can be done in the same process context
239 or a forked process, or another thread,
240 <p>
241 The protocol callback functions are called for a handful of events
242 including http requests coming in, websocket connections becoming
243 established, and data arriving; it's also called periodically to allow
244 async transmission.
245 <p>
246 HTTP requests are sent always to the FIRST protocol in <tt><b>protocol</b></tt>, since
247 at that time websocket protocol has not been negotiated.  Other
248 protocols after the first one never see any HTTP callack activity.
249 <p>
250 The server created is a simple http server by default; part of the
251 websocket standard is upgrading this http connection to a websocket one.
252 <p>
253 This allows the same server to provide files like scripts and favicon /
254 images or whatever over http and dynamic data over websockets all in
255 one place; they're all handled in the user callback.
256 </blockquote>
257 <hr>
258 <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>
259 <i>int</i>
260 <b>libwebsockets_fork_service_loop</b>
261 (<i>struct libwebsocket_context *</i> <b>this</b>)
262 <h3>Arguments</h3>
263 <dl>
264 <dt><b>this</b>
265 <dd>server context returned by creation function
266 </dl>
267 <hr>
268 <h2>libwebsockets_get_protocol - Returns a protocol pointer from a websocket connection.</h2>
269 <i>const struct libwebsocket_protocols *</i>
270 <b>libwebsockets_get_protocol</b>
271 (<i>struct libwebsocket *</i> <b>wsi</b>)
272 <h3>Arguments</h3>
273 <dl>
274 <dt><b>wsi</b>
275 <dd>pointer to struct websocket you want to know the protocol of
276 </dl>
277 <h3>Description</h3>
278 <blockquote>
279 <p>
280 This is useful to get the protocol to broadcast back to from inside
281 the callback.
282 </blockquote>
283 <hr>
284 <h2>libwebsockets_broadcast - Sends a buffer to the callback for all active connections of the given protocol.</h2>
285 <i>int</i>
286 <b>libwebsockets_broadcast</b>
287 (<i>const struct libwebsocket_protocols *</i> <b>protocol</b>,
288 <i>unsigned char *</i> <b>buf</b>,
289 <i>size_t</i> <b>len</b>)
290 <h3>Arguments</h3>
291 <dl>
292 <dt><b>protocol</b>
293 <dd>pointer to the protocol you will broadcast to all members of
294 <dt><b>buf</b>
295 <dd>buffer containing the data to be broadcase.  NOTE: this has to be
296 allocated with LWS_SEND_BUFFER_PRE_PADDING valid bytes before
297 the pointer and LWS_SEND_BUFFER_POST_PADDING afterwards in the
298 case you are calling this function from callback context.
299 <dt><b>len</b>
300 <dd>length of payload data in buf, starting from buf.
301 </dl>
302 <h3>Description</h3>
303 <blockquote>
304 This function allows bulk sending of a packet to every connection using
305 the given protocol.  It does not send the data directly; instead it calls
306 the callback with a reason type of LWS_CALLBACK_BROADCAST.  If the callback
307 wants to actually send the data for that connection, the callback itself
308 should call <b>libwebsocket_write</b>.
309 <p>
310 <b>libwebsockets_broadcast</b> can be called from another fork context without
311 having to take any care about data visibility between the processes, it'll
312 "just work".
313 </blockquote>
314 <hr>
315 <h2>libwebsocket_write - Apply protocol then write data to client</h2>
316 <i>int</i>
317 <b>libwebsocket_write</b>
318 (<i>struct libwebsocket *</i> <b>wsi</b>,
319 <i>unsigned char *</i> <b>buf</b>,
320 <i>size_t</i> <b>len</b>,
321 <i>enum libwebsocket_write_protocol</i> <b>protocol</b>)
322 <h3>Arguments</h3>
323 <dl>
324 <dt><b>wsi</b>
325 <dd>Websocket instance (available from user callback)
326 <dt><b>buf</b>
327 <dd>The data to send.  For data being sent on a websocket
328 connection (ie, not default http), this buffer MUST have
329 LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE the pointer
330 and an additional LWS_SEND_BUFFER_POST_PADDING bytes valid
331 in the buffer after (buf + len).  This is so the protocol
332 header and trailer data can be added in-situ.
333 <dt><b>len</b>
334 <dd>Count of the data bytes in the payload starting from buf
335 <dt><b>protocol</b>
336 <dd>Use LWS_WRITE_HTTP to reply to an http connection, and one
337 of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate
338 data on a websockets connection.  Remember to allow the extra
339 bytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT
340 are used.
341 </dl>
342 <h3>Description</h3>
343 <blockquote>
344 This function provides the way to issue data back to the client
345 for both http and websocket protocols.
346 <p>
347 In the case of sending using websocket protocol, be sure to allocate
348 valid storage before and after buf as explained above.  This scheme
349 allows maximum efficiency of sending data and protocol in a single
350 packet while not burdening the user code with any protocol knowledge.
351 </blockquote>
352 <hr>
353 <h2>libwebsockets_serve_http_file - Send a file back to the client using http</h2>
354 <i>int</i>
355 <b>libwebsockets_serve_http_file</b>
356 (<i>struct libwebsocket *</i> <b>wsi</b>,
357 <i>const char *</i> <b>file</b>,
358 <i>const char *</i> <b>content_type</b>)
359 <h3>Arguments</h3>
360 <dl>
361 <dt><b>wsi</b>
362 <dd>Websocket instance (available from user callback)
363 <dt><b>file</b>
364 <dd>The file to issue over http
365 <dt><b>content_type</b>
366 <dd>The http content type, eg, text/html
367 </dl>
368 <h3>Description</h3>
369 <blockquote>
370 This function is intended to be called from the callback in response
371 to http requests from the client.  It allows the callback to issue
372 local files down the http link in a single step.
373 </blockquote>
374 <hr>
375 <h2>libwebsockets_remaining_packet_payload - Bytes to come before "overall" rx packet is complete</h2>
376 <i>size_t</i>
377 <b>libwebsockets_remaining_packet_payload</b>
378 (<i>struct libwebsocket *</i> <b>wsi</b>)
379 <h3>Arguments</h3>
380 <dl>
381 <dt><b>wsi</b>
382 <dd>Websocket instance (available from user callback)
383 </dl>
384 <h3>Description</h3>
385 <blockquote>
386 This function is intended to be called from the callback if the
387 user code is interested in "complete packets" from the client.
388 libwebsockets just passes through payload as it comes and issues a buffer
389 additionally when it hits a built-in limit.  The LWS_CALLBACK_RECEIVE
390 callback handler can use this API to find out if the buffer it has just
391 been given is the last piece of a "complete packet" from the client --
392 when that is the case <b>libwebsockets_remaining_packet_payload</b> will return
393 0.
394 <p>
395 Many protocols won't care becuse their packets are always small.
396 </blockquote>
397 <hr>
398 <h2>libwebsocket_client_connect - Connect to another websocket server</h2>
399 <i>struct libwebsocket *</i>
400 <b>libwebsocket_client_connect</b>
401 (<i>struct libwebsocket_context *</i> <b>this</b>,
402 <i>const char *</i> <b>address</b>,
403 <i>int</i> <b>port</b>,
404 <i>int</i> <b>ssl_connection</b>,
405 <i>const char *</i> <b>path</b>,
406 <i>const char *</i> <b>host</b>,
407 <i>const char *</i> <b>origin</b>,
408 <i>const char *</i> <b>protocol</b>,
409 <i>int</i> <b>ietf_version_or_minus_one</b>)
410 <h3>Arguments</h3>
411 <dl>
412 <dt><b>this</b>
413 <dd>Websocket context
414 <dt><b>address</b>
415 <dd>Remote server address, eg, "myserver.com"
416 <dt><b>port</b>
417 <dd>Port to connect to on the remote server, eg, 80
418 <dt><b>ssl_connection</b>
419 <dd>0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
420 signed certs
421 <dt><b>path</b>
422 <dd>Websocket path on server
423 <dt><b>host</b>
424 <dd>Hostname on server
425 <dt><b>origin</b>
426 <dd>Socket origin name
427 <dt><b>protocol</b>
428 <dd>Comma-separated list of protocols being asked for from
429 the server, or just one.  The server will pick the one it
430 likes best.
431 <dt><b>ietf_version_or_minus_one</b>
432 <dd>-1 to ask to connect using the default, latest
433 protocol supported, or the specific protocol ordinal
434 </dl>
435 <h3>Description</h3>
436 <blockquote>
437 This function creates a connection to a remote server
438 </blockquote>
439 <hr>
440 <h2>callback - User server actions</h2>
441 <i>int</i>
442 <b>callback</b>
443 (<i>struct libwebsocket_context *</i> <b>this</b>,
444 <i>struct libwebsocket *</i> <b>wsi</b>,
445 <i>enum libwebsocket_callback_reasons</i> <b>reason</b>,
446 <i>void *</i> <b>user</b>,
447 <i>void *</i> <b>in</b>,
448 <i>size_t</i> <b>len</b>)
449 <h3>Arguments</h3>
450 <dl>
451 <dt><b>this</b>
452 <dd>Websockets context
453 <dt><b>wsi</b>
454 <dd>Opaque websocket instance pointer
455 <dt><b>reason</b>
456 <dd>The reason for the call
457 <dt><b>user</b>
458 <dd>Pointer to per-session user data allocated by library
459 <dt><b>in</b>
460 <dd>Pointer used for some callback reasons
461 <dt><b>len</b>
462 <dd>Length set for some callback reasons
463 </dl>
464 <h3>Description</h3>
465 <blockquote>
466 This callback is the way the user controls what is served.  All the
467 protocol detail is hidden and handled by the library.
468 <p>
469 For each connection / session there is user data allocated that is
470 pointed to by "user".  You set the size of this user data area when
471 the library is initialized with libwebsocket_create_server.
472 <p>
473 You get an opportunity to initialize user data when called back with
474 LWS_CALLBACK_ESTABLISHED reason.
475 </blockquote>
476 <h3>LWS_CALLBACK_ESTABLISHED</h3>
477 <blockquote>
478 after the server completes a handshake with
479 an incoming client
480 </blockquote>
481 <h3>LWS_CALLBACK_CLIENT_ESTABLISHED</h3>
482 <blockquote>
483 after your client connection completed
484 a handshake with the remote server
485 </blockquote>
486 <h3>LWS_CALLBACK_CLOSED</h3>
487 <blockquote>
488 when the websocket session ends
489 </blockquote>
490 <h3>LWS_CALLBACK_BROADCAST</h3>
491 <blockquote>
492 signal to send to client (you would use
493 <b>libwebsocket_write</b> taking care about the
494 special buffer requirements
495 </blockquote>
496 <h3>LWS_CALLBACK_RECEIVE</h3>
497 <blockquote>
498 data has appeared for this server endpoint from a
499 remote client, it can be found at *in and is
500 len bytes long
501 </blockquote>
502 <h3>LWS_CALLBACK_CLIENT_RECEIVE_PONG</h3>
503 <blockquote>
504 if you elected to see PONG packets,
505 they appear with this callback reason.  PONG
506 packets only exist in 04+ protocol
507 </blockquote>
508 <h3>LWS_CALLBACK_CLIENT_RECEIVE</h3>
509 <blockquote>
510 data has appeared from the server for the
511 client connection, it can be found at *in and
512 is len bytes long
513 </blockquote>
514 <h3>LWS_CALLBACK_HTTP</h3>
515 <blockquote>
516 an http request has come from a client that is not
517 asking to upgrade the connection to a websocket
518 one.  This is a chance to serve http content,
519 for example, to send a script to the client
520 which will then open the websockets connection.
521 <tt><b>in</b></tt> points to the URI path requested and
522 <b>libwebsockets_serve_http_file</b> makes it very
523 simple to send back a file to the client.
524 </blockquote>
525 <h3>LWS_CALLBACK_CLIENT_WRITEABLE</h3>
526 <blockquote>
527 if you call
528 <b>libwebsocket_callback_on_writable</b> on a connection, you will
529 get this callback coming when the connection socket is able to
530 accept another write packet without blocking.  If it already
531 was able to take another packet without blocking, you'll get
532 this callback at the next call to the service loop function.
533 </blockquote>
534 <h3>LWS_CALLBACK_FILTER_NETWORK_CONNECTION</h3>
535 <blockquote>
536 called when a client connects to
537 the server at network level; the connection is accepted but then
538 passed to this callback to decide whether to hang up immediately
539 or not, based on the client IP.  <tt><b>user</b></tt> contains the connection
540 socket's descriptor.  Return non-zero to terminate
541 the connection before sending or receiving anything.
542 Because this happens immediately after the network connection
543 from the client, there's no websocket protocol selected yet so
544 this callback is issued only to protocol 0.
545 </blockquote>
546 <h3>LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION</h3>
547 <blockquote>
548 called when the handshake has
549 been received and parsed from the client, but the response is
550 not sent yet.  Return non-zero to disallow the connection.
551 <tt><b>user</b></tt> is a pointer to an array of struct lws_tokens, you can
552 use the header enums lws_token_indexes from libwebsockets.h
553 to check for and read the supported header presence and
554 content before deciding to allow the handshake to proceed or
555 to kill the connection.
556 <p>
557 <p>
558 The next four reasons are optional and only need taking care of if you
559 will be integrating libwebsockets sockets into an external polling
560 array.
561 </blockquote>
562 <h3>LWS_CALLBACK_ADD_POLL_FD</h3>
563 <blockquote>
564 libwebsocket deals with its <b>poll</b> loop
565 internally, but in the case you are integrating with another
566 server you will need to have libwebsocket sockets share a
567 polling array with the other server.  This and the other
568 POLL_FD related callbacks let you put your specialized
569 poll array interface code in the callback for protocol 0, the
570 first protocol you support, usually the HTTP protocol in the
571 serving case.  This callback happens when a socket needs to be
572 </blockquote>
573 <h3>added to the polling loop</h3>
574 <blockquote>
575 <tt><b>user</b></tt> contains the fd, and
576 <tt><b>len</b></tt> is the events bitmap (like, POLLIN).  If you are using the
577 internal polling loop (the "service" callback), you can just
578 ignore these callbacks.
579 </blockquote>
580 <h3>LWS_CALLBACK_DEL_POLL_FD</h3>
581 <blockquote>
582 This callback happens when a socket descriptor
583 needs to be removed from an external polling array.  <tt><b>user</b></tt> is
584 the socket desricptor.  If you are using the internal polling
585 loop, you can just ignore it.
586 </blockquote>
587 <h3>LWS_CALLBACK_SET_MODE_POLL_FD</h3>
588 <blockquote>
589 This callback happens when libwebsockets
590 wants to modify the events for the socket descriptor in <tt><b>user</b></tt>.
591 The handler should OR <tt><b>len</b></tt> on to the events member of the pollfd
592 struct for this socket descriptor.  If you are using the
593 internal polling loop, you can just ignore it.
594 </blockquote>
595 <h3>LWS_CALLBACK_CLEAR_MODE_POLL_FD</h3>
596 <blockquote>
597 This callback occurs when libwebsockets
598 wants to modify the events for the socket descriptor in <tt><b>user</b></tt>.
599 The handler should AND ~<tt><b>len</b></tt> on to the events member of the
600 pollfd struct for this socket descriptor.  If you are using the
601 internal polling loop, you can just ignore it.
602 </blockquote>
603 <hr>
604 <h2>struct libwebsocket_protocols - List of protocols and handlers server supports.</h2>
605 <b>struct libwebsocket_protocols</b> {<br>
606 &nbsp; &nbsp; <i>const char *</i> <b>name</b>;<br>
607 &nbsp; &nbsp; <i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context * this,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len)</i>;<br>
608 &nbsp; &nbsp; <i>size_t</i> <b>per_session_data_size</b>;<br>
609 &nbsp; &nbsp; <i>struct libwebsocket_context *</i> <b>owning_server</b>;<br>
610 &nbsp; &nbsp; <i>int</i> <b>broadcast_socket_port</b>;<br>
611 &nbsp; &nbsp; <i>int</i> <b>broadcast_socket_user_fd</b>;<br>
612 &nbsp; &nbsp; <i>int</i> <b>protocol_index</b>;<br>
613 };<br>
614 <h3>Members</h3>
615 <dl>
616 <dt><b>name</b>
617 <dd>Protocol name that must match the one given in the client
618 Javascript new WebSocket(url, 'protocol') name
619 <dt><b>callback</b>
620 <dd>The service callback used for this protocol.  It allows the
621 service action for an entire protocol to be encapsulated in
622 the protocol-specific callback
623 <dt><b>per_session_data_size</b>
624 <dd>Each new connection using this protocol gets
625 this much memory allocated on connection establishment and
626 freed on connection takedown.  A pointer to this per-connection
627 allocation is passed into the callback in the 'user' parameter
628 <dt><b>owning_server</b>
629 <dd>the server init call fills in this opaque pointer when
630 registering this protocol with the server.
631 <dt><b>broadcast_socket_port</b>
632 <dd>the server init call fills this in with the
633 localhost port number used to forward broadcasts for this
634 protocol
635 <dt><b>broadcast_socket_user_fd</b>
636 <dd>the server init call fills this in ... the <b>main</b>
637 process context can write to this socket to perform broadcasts
638 (use the <b>libwebsockets_broadcast</b> api to do this instead,
639 it works from any process context)
640 <dt><b>protocol_index</b>
641 <dd>which protocol we are starting from zero
642 </dl>
643 <h3>Description</h3>
644 <blockquote>
645 This structure represents one protocol supported by the server.  An
646 array of these structures is passed to <b>libwebsocket_create_server</b>
647 allows as many protocols as you like to be handled by one server.
648 </blockquote>
649 <hr>