forked from warmcat/libwebsockets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibwebsockets-api-doc.html
2318 lines (2318 loc) · 77.3 KB
/
libwebsockets-api-doc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<h2>lws_client_reset - retarget a connected wsi to start over with a new connection (ie, redirect) this only works if still in HTTP, ie, not upgraded yet</h2>
<i>struct lws *</i>
<b>lws_client_reset</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>int</i> <b>ssl</b>,
<i>const char *</i> <b>address</b>,
<i>int</i> <b>port</b>,
<i>const char *</i> <b>path</b>,
<i>const char *</i> <b>host</b>)
<h3>Arguments</h3>
<dl>
</dl>
<h3>wsi</h3>
<blockquote>
connection to reset
</blockquote>
<h3>address</h3>
<blockquote>
network address of the new server
</blockquote>
<h3>port</h3>
<blockquote>
port to connect to
</blockquote>
<h3>path</h3>
<blockquote>
uri path to connect to on the new server
</blockquote>
<h3>host</h3>
<blockquote>
host header to send to the new server
</blockquote>
<hr>
<h2>lws_client_connect_via_info - Connect to another websocket server</h2>
<i>struct lws *</i>
<b>lws_client_connect_via_info</b>
(<i>struct lws_client_connect_info *</i> <b>i</b>)
<h3>Arguments</h3>
<dl>
<dt><b>i</b>
<dd>pointer to lws_client_connect_info struct
</dl>
<h3>Description</h3>
<blockquote>
This function creates a connection to a remote server
</blockquote>
<hr>
<h2>lws_client_connect_extended - Connect to another websocket server DEPRECATED use lws_client_connect_via_info</h2>
<i>struct lws *</i>
<b>lws_client_connect_extended</b>
(<i>struct lws_context *</i> <b>context</b>,
<i>const char *</i> <b>address</b>,
<i>int</i> <b>port</b>,
<i>int</i> <b>ssl_connection</b>,
<i>const char *</i> <b>path</b>,
<i>const char *</i> <b>host</b>,
<i>const char *</i> <b>origin</b>,
<i>const char *</i> <b>protocol</b>,
<i>int</i> <b>ietf_version_or_minus_one</b>,
<i>void *</i> <b>userdata</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
<dt><b>address</b>
<dd>Remote server address, eg, "myserver.com"
<dt><b>port</b>
<dd>Port to connect to on the remote server, eg, 80
<dt><b>ssl_connection</b>
<dd>0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
signed certs
<dt><b>path</b>
<dd>Websocket path on server
<dt><b>host</b>
<dd>Hostname on server
<dt><b>origin</b>
<dd>Socket origin name
<dt><b>protocol</b>
<dd>Comma-separated list of protocols being asked for from
the server, or just one. The server will pick the one it
likes best.
<dt><b>ietf_version_or_minus_one</b>
<dd>-1 to ask to connect using the default, latest
protocol supported, or the specific protocol ordinal
<dt><b>userdata</b>
<dd>Pre-allocated user data
</dl>
<h3>Description</h3>
<blockquote>
This function creates a connection to a remote server
</blockquote>
<hr>
<h2>lws_client_connect - Connect to another websocket server DEPRECATED use lws_client_connect_via_info</h2>
<i>struct lws *</i>
<b>lws_client_connect</b>
(<i>struct lws_context *</i> <b>context</b>,
<i>const char *</i> <b>address</b>,
<i>int</i> <b>port</b>,
<i>int</i> <b>ssl_connection</b>,
<i>const char *</i> <b>path</b>,
<i>const char *</i> <b>host</b>,
<i>const char *</i> <b>origin</b>,
<i>const char *</i> <b>protocol</b>,
<i>int</i> <b>ietf_version_or_minus_one</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
<dt><b>address</b>
<dd>Remote server address, eg, "myserver.com"
<dt><b>port</b>
<dd>Port to connect to on the remote server, eg, 80
<dt><b>ssl_connection</b>
<dd>0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
signed certs
<dt><b>path</b>
<dd>Websocket path on server
<dt><b>host</b>
<dd>Hostname on server
<dt><b>origin</b>
<dd>Socket origin name
<dt><b>protocol</b>
<dd>Comma-separated list of protocols being asked for from
the server, or just one. The server will pick the one it
likes best. If you don't want to specify a protocol, which is
legal, use NULL here.
<dt><b>ietf_version_or_minus_one</b>
<dd>-1 to ask to connect using the default, latest
protocol supported, or the specific protocol ordinal
</dl>
<h3>Description</h3>
<blockquote>
This function creates a connection to a remote server
</blockquote>
<hr>
<h2>lws_http_transaction_completed_client - wait for new http transaction or close</h2>
<i>int LWS_WARN_UNUSED_RESULT</i>
<b>lws_http_transaction_completed_client</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>websocket connection
</dl>
<h3>Description</h3>
<blockquote>
Returns 1 if the HTTP connection must close now
Returns 0 and resets connection to wait for new HTTP header /
transaction if possible
</blockquote>
<hr>
<h2>lws_get_library_version - </h2>
<i>const char *</i>
<b>lws_get_library_version</b>
(<i></i> <b>void</b>)
<h3>Arguments</h3>
<dl>
<dt><b>void</b>
<dd>no arguments
</dl>
<h3>Description</h3>
<blockquote>
<p>
returns a const char * to a string like "1.1 178d78c"
representing the library version followed by the git head hash it
was built from
</blockquote>
<hr>
<h2>lws_init_vhost_client_ssl - also enable client SSL on an existing vhost</h2>
<i>int</i>
<b>lws_init_vhost_client_ssl</b>
(<i>const struct lws_context_creation_info *</i> <b>info</b>,
<i>struct lws_vhost *</i> <b>vhost</b>)
<h3>Arguments</h3>
<dl>
<dt><b>info</b>
<dd>client ssl related info
<dt><b>vhost</b>
<dd>which vhost to initialize client ssl operations on
</dl>
<h3>Description</h3>
<blockquote>
You only need to call this if you plan on using SSL client connections on
the vhost. For non-SSL client connections, it's not necessary to call this.
<p>
The following members of <tt><b>info</b></tt> are used during the call
<p>
- <tt><b>options</b></tt> must have LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT set,
otherwise the call does nothing
- <tt><b>provided_client_ssl_ctx</b></tt> must be NULL to get a generated client
ssl context, otherwise you can pass a prepared one in by setting it
- <tt><b>ssl_cipher_list</b></tt> may be NULL or set to the client valid cipher list
- <tt><b>ssl_ca_filepath</b></tt> may be NULL or client cert filepath
- <tt><b>ssl_cert_filepath</b></tt> may be NULL or client cert filepath
- <tt><b>ssl_private_key_filepath</b></tt> may be NULL or client cert private key
<p>
You must create your vhost explicitly if you want to use this, so you have
a pointer to the vhost. Create the context first with the option flag
LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call <b>lws_create_vhost</b> with
the same info struct.
</blockquote>
<hr>
<h2>lws_create_context - Create the websocket handler</h2>
<i>struct lws_context *</i>
<b>lws_create_context</b>
(<i>struct lws_context_creation_info *</i> <b>info</b>)
<h3>Arguments</h3>
<dl>
<dt><b>info</b>
<dd>pointer to struct with parameters
</dl>
<h3>Description</h3>
<blockquote>
This function creates the listening socket (if serving) and takes care
of all initialization in one step.
<p>
After initialization, it returns a struct lws_context * that
represents this server. After calling, user code needs to take care
of calling <b>lws_service</b> with the context pointer to get the
server's sockets serviced. This must be done in the same process
context as the initialization call.
<p>
The protocol callback functions are called for a handful of events
including http requests coming in, websocket connections becoming
established, and data arriving; it's also called periodically to allow
async transmission.
<p>
HTTP requests are sent always to the FIRST protocol in <tt><b>protocol</b></tt>, since
at that time websocket protocol has not been negotiated. Other
protocols after the first one never see any HTTP callack activity.
<p>
The server created is a simple http server by default; part of the
websocket standard is upgrading this http connection to a websocket one.
<p>
This allows the same server to provide files like scripts and favicon /
images or whatever over http and dynamic data over websockets all in
one place; they're all handled in the user callback.
</blockquote>
<hr>
<h2>lws_context_destroy - Destroy the websocket context</h2>
<i>void</i>
<b>lws_context_destroy</b>
(<i>struct lws_context *</i> <b>context</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
</dl>
<h3>Description</h3>
<blockquote>
This function closes any active connections and then frees the
context. After calling this, any further use of the context is
undefined.
</blockquote>
<hr>
<h2>lws_set_extension_option - </h2>
<i>int</i>
<b>lws_set_extension_option</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>const char *</i> <b>ext_name</b>,
<i>const char *</i> <b>opt_name</b>,
<i>const char *</i> <b>opt_val</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>websocket connection
<dt><b>ext_name</b>
<dd>name of ext, like "permessage-deflate"
<dt><b>opt_name</b>
<dd>name of option, like "rx_buf_size"
<dt><b>opt_val</b>
<dd>value to set option to
</dl>
<hr>
<h2>lws_return_http_status - Return simple http status</h2>
<i>int</i>
<b>lws_return_http_status</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>unsigned int</i> <b>code</b>,
<i>const char *</i> <b>html_body</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Websocket instance (available from user callback)
<dt><b>code</b>
<dd>Status index, eg, 404
<dt><b>html_body</b>
<dd>User-readable HTML description < 1KB, or NULL
</dl>
<h3>Description</h3>
<blockquote>
Helper to report HTTP errors back to the client cleanly and
consistently
</blockquote>
<hr>
<h2>lejp_construct - prepare a struct lejp_ctx for use</h2>
<i>void</i>
<b>lejp_construct</b>
(<i>struct lejp_ctx *</i> <b>ctx</b>,
<i>char (*</i><b>callback</b>) <i>(struct lejp_ctx *ctx, char reason)</i>,
<i>void *</i> <b>user</b>,
<i>const char *const *</i> <b>paths</b>,
<i>unsigned char</i> <b>count_paths</b>)
<h3>Arguments</h3>
<dl>
<dt><b>ctx</b>
<dd>pointer to your struct lejp_ctx
<dt><b>callback</b>
<dd>your user callback which will received parsed tokens
<dt><b>user</b>
<dd>optional user data pointer untouched by lejp
<dt><b>paths</b>
<dd>your array of name elements you are interested in
<dt><b>count_paths</b>
<dd><b>ARRAY_SIZE</b> of <tt><b>paths</b></tt>
</dl>
<h3>Description</h3>
<blockquote>
Prepares your context struct for use with lejp
</blockquote>
<hr>
<h2>lejp_destruct - retire a previously constructed struct lejp_ctx</h2>
<i>void</i>
<b>lejp_destruct</b>
(<i>struct lejp_ctx *</i> <b>ctx</b>)
<h3>Arguments</h3>
<dl>
<dt><b>ctx</b>
<dd>pointer to your struct lejp_ctx
</dl>
<h3>Description</h3>
<blockquote>
lejp does not perform any allocations, but since your user code might, this
provides a one-time LEJPCB_DESTRUCTED callback at destruction time where
you can clean up in your callback.
</blockquote>
<hr>
<h2>lejp_change_callback - switch to a different callback from now on</h2>
<i>void</i>
<b>lejp_change_callback</b>
(<i>struct lejp_ctx *</i> <b>ctx</b>,
<i>char (*</i><b>callback</b>) <i>(struct lejp_ctx *ctx, char reason)</i>)
<h3>Arguments</h3>
<dl>
<dt><b>ctx</b>
<dd>pointer to your struct lejp_ctx
<dt><b>callback</b>
<dd>your user callback which will received parsed tokens
</dl>
<h3>Description</h3>
<blockquote>
This tells the old callback it was destroyed, in case you want to take any
action because that callback "lost focus", then changes to the new
callback and tells it first that it was constructed, and then started.
<p>
Changing callback is a cheap and powerful trick to split out handlers
according to information earlier in the parse. For example you may have
a JSON pair "schema" whose value defines what can be expected for the rest
of the JSON. Rather than having one huge callback for all cases, you can
have an initial one looking for "schema" which then calls
<b>lejp_change_callback</b> to a handler specific for the schema.
<p>
Notice that afterwards, you need to construct the context again anyway to
parse another JSON object, and the callback is reset then to the main,
schema-interpreting one. The construction action is very lightweight.
</blockquote>
<hr>
<h2>lejp_parse - interpret some more incoming data incrementally</h2>
<i>int</i>
<b>lejp_parse</b>
(<i>struct lejp_ctx *</i> <b>ctx</b>,
<i>const unsigned char *</i> <b>json</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>ctx</b>
<dd>previously constructed parsing context
<dt><b>json</b>
<dd>char buffer with the new data to interpret
<dt><b>len</b>
<dd>amount of data in the buffer
</dl>
<h3>Description</h3>
<blockquote>
Because lejp is a stream parser, it incrementally parses as new data
becomes available, maintaining all state in the context struct. So an
incomplete JSON is a normal situation, getting you a LEJP_CONTINUE
return, signalling there's no error but to call again with more data when
it comes to complete the parsing. Successful parsing completes with a
0 or positive integer indicating how much of the last input buffer was
unused.
</blockquote>
<hr>
<h2>lws_set_timeout - marks the wsi as subject to a timeout</h2>
<i>void</i>
<b>lws_set_timeout</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>enum pending_timeout</i> <b>reason</b>,
<i>int</i> <b>secs</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Websocket connection instance
<dt><b>reason</b>
<dd>timeout reason
<dt><b>secs</b>
<dd>how many seconds
</dl>
<h3>Description</h3>
<blockquote>
<p>
You will not need this unless you are doing something special
</blockquote>
<hr>
<h2>lws_get_urlarg_by_name - return pointer to arg value if present</h2>
<i>LWS_EXTERN const char *</i>
<b>lws_get_urlarg_by_name</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>const char *</i> <b>name</b>,
<i>char *</i> <b>buf</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>the connection to check
<dt><b>name</b>
<dd>the arg name, like "token="
<dt><b>buf</b>
<dd>the buffer to receive the urlarg (including the name= part)
<dt><b>len</b>
<dd>the length of the buffer to receive the urlarg
</dl>
<h3>Description</h3>
<blockquote>
Returns NULL if not found or a pointer inside <tt><b>buf</b></tt> to just after the
name= part.
</blockquote>
<hr>
<h2>lws_get_peer_simple - Get client address information without RDNS</h2>
<i>const char *</i>
<b>lws_get_peer_simple</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>char *</i> <b>name</b>,
<i>int</i> <b>namelen</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Local struct lws associated with
<dt><b>name</b>
<dd>Buffer to take client address name
</dl>
<h3>Description</h3>
<blockquote>
This provides a 123.123.123.123 type IP address in <tt><b>name</b></tt> from the
peer that has connected to <tt><b>wsi</b></tt>
</blockquote>
<hr>
<h2>lws_get_peer_addresses - Get client address information</h2>
<i>void</i>
<b>lws_get_peer_addresses</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>lws_sockfd_type</i> <b>fd</b>,
<i>char *</i> <b>name</b>,
<i>int</i> <b>name_len</b>,
<i>char *</i> <b>rip</b>,
<i>int</i> <b>rip_len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Local struct lws associated with
<dt><b>fd</b>
<dd>Connection socket descriptor
<dt><b>name</b>
<dd>Buffer to take client address name
<dt><b>name_len</b>
<dd>Length of client address name buffer
<dt><b>rip</b>
<dd>Buffer to take client address IP dotted quad
<dt><b>rip_len</b>
<dd>Length of client address IP buffer
</dl>
<h3>Description</h3>
<blockquote>
This function fills in <tt><b>name</b></tt> and <tt><b>rip</b></tt> with the name and IP of
the client connected with socket descriptor <tt><b>fd</b></tt>. Names may be
truncated if there is not enough room. If either cannot be
determined, they will be returned as valid zero-length strings.
</blockquote>
<hr>
<h2>lws_context_user - get the user data associated with the context</h2>
<i>LWS_EXTERN void *</i>
<b>lws_context_user</b>
(<i>struct lws_context *</i> <b>context</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
</dl>
<h3>Description</h3>
<blockquote>
This returns the optional user allocation that can be attached to
the context the sockets live in at context_create time. It's a way
to let all sockets serviced in the same context share data without
using globals statics in the user code.
</blockquote>
<hr>
<h2>lws_callback_all_protocol - Callback all connections using the given protocol with the given reason</h2>
<i>int</i>
<b>lws_callback_all_protocol</b>
(<i>struct lws_context *</i> <b>context</b>,
<i>const struct lws_protocols *</i> <b>protocol</b>,
<i>int</i> <b>reason</b>)
<h3>Arguments</h3>
<dl>
<dt><b>protocol</b>
<dd>Protocol whose connections will get callbacks
<dt><b>reason</b>
<dd>Callback reason index
</dl>
<hr>
<h2>lws_callback_all_protocol_vhost - Callback all connections using the given protocol with the given reason</h2>
<i>int</i>
<b>lws_callback_all_protocol_vhost</b>
(<i>struct lws_vhost *</i> <b>vh</b>,
<i>const struct lws_protocols *</i> <b>protocol</b>,
<i>int</i> <b>reason</b>)
<h3>Arguments</h3>
<dl>
<dt><b>vh</b>
<dd>Vhost whose connections will get callbacks
<dt><b>protocol</b>
<dd>Which protocol to match
<dt><b>reason</b>
<dd>Callback reason index
</dl>
<hr>
<h2>lws_get_socket_fd - returns the socket file descriptor</h2>
<i>int</i>
<b>lws_get_socket_fd</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Websocket connection instance
</dl>
<h3>Description</h3>
<blockquote>
<p>
You will not need this unless you are doing something special
</blockquote>
<hr>
<h2>lws_rx_flow_control - Enable and disable socket servicing for received packets.</h2>
<i>int</i>
<b>lws_rx_flow_control</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>int</i> <b>enable</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Websocket connection instance to get callback for
<dt><b>enable</b>
<dd>0 = disable read servicing for this connection, 1 = enable
</dl>
<h3>Description</h3>
<blockquote>
<p>
If the output side of a server process becomes choked, this allows flow
control for the input side.
</blockquote>
<hr>
<h2>lws_rx_flow_allow_all_protocol - Allow all connections with this protocol to receive</h2>
<i>void</i>
<b>lws_rx_flow_allow_all_protocol</b>
(<i>const struct lws_context *</i> <b>context</b>,
<i>const struct lws_protocols *</i> <b>protocol</b>)
<h3>Arguments</h3>
<dl>
<dt><b>protocol</b>
<dd>all connections using this protocol will be allowed to receive
</dl>
<h3>Description</h3>
<blockquote>
<p>
When the user server code realizes it can accept more input, it can
call this to have the RX flow restriction removed from all connections using
the given protocol.
</blockquote>
<hr>
<h2>lws_canonical_hostname - returns this host's hostname</h2>
<i>const char *</i>
<b>lws_canonical_hostname</b>
(<i>struct lws_context *</i> <b>context</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
</dl>
<h3>Description</h3>
<blockquote>
<p>
This is typically used by client code to fill in the host parameter
when making a client connection. You can only call it after the context
has been created.
</blockquote>
<hr>
<h2>lws_set_proxy - Setups proxy to lws_context.</h2>
<i>int</i>
<b>lws_set_proxy</b>
(<i>struct lws_vhost *</i> <b>vhost</b>,
<i>const char *</i> <b>proxy</b>)
<h3>Arguments</h3>
<dl>
<dt><b>proxy</b>
<dd>pointer to c string containing proxy in format address:port
</dl>
<h3>Description</h3>
<blockquote>
Returns 0 if proxy string was parsed and proxy was setup.
Returns -1 if <tt><b>proxy</b></tt> is NULL or has incorrect format.
<p>
This is only required if your OS does not provide the http_proxy
environment variable (eg, OSX)
<p>
IMPORTANT! You should call this function right after creation of the
lws_context and before call to connect. If you call this
function after connect behavior is undefined.
This function will override proxy settings made on lws_context
creation with <b>genenv</b> call.
</blockquote>
<hr>
<h2>lws_get_protocol - Returns a protocol pointer from a websocket connection.</h2>
<i>const struct lws_protocols *</i>
<b>lws_get_protocol</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>pointer to struct websocket you want to know the protocol of
</dl>
<h3>Description</h3>
<blockquote>
<p>
Some apis can act on all live connections of a given protocol,
this is how you can get a pointer to the active protocol if needed.
</blockquote>
<hr>
<h2>lwsl_timestamp - </h2>
<i>int</i>
<b>lwsl_timestamp</b>
(<i>int</i> <b>level</b>,
<i>char *</i> <b>p</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>level</b>
<dd>logging level
<dt><b>p</b>
<dd>char * buffer to take timestamp
<dt><b>len</b>
<dd>length of p
</dl>
<h3>Description</h3>
<blockquote>
returns length written in p
</blockquote>
<hr>
<h2>lws_set_log_level - Set the logging bitfield</h2>
<i>void</i>
<b>lws_set_log_level</b>
(<i>int</i> <b>level</b>,
<i>void (*</i><b>func</b>) <i>(int level, const char *line)</i>)
<h3>Arguments</h3>
<dl>
<dt><b>level</b>
<dd>OR together the LLL_ debug contexts you want output from
</dl>
<h3>Description</h3>
<blockquote>
log level defaults to "err", "warn" and "notice" contexts enabled and
emission on stderr.
</blockquote>
<hr>
<h2>lws_is_ssl - Find out if connection is using SSL</h2>
<i>int</i>
<b>lws_is_ssl</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>websocket connection to check
</dl>
<h3>Description</h3>
<blockquote>
Returns 0 if the connection is not using SSL, 1 if using SSL and
using verified cert, and 2 if using SSL but the cert was not
checked (appears for client wsi told to skip check on connection)
</blockquote>
<hr>
<h2>lws_partial_buffered - find out if lws buffered the last write</h2>
<i>int</i>
<b>lws_partial_buffered</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>websocket connection to check
</dl>
<h3>Description</h3>
<blockquote>
Returns 1 if you cannot use lws_write because the last
write on this connection is still buffered, and can't be cleared without
returning to the service loop and waiting for the connection to be
writeable again.
<p>
If you will try to do >1 lws_write call inside a single
WRITEABLE callback, you must check this after every write and bail if
set, ask for a new writeable callback and continue writing from there.
<p>
This is never set at the start of a writeable callback, but any write
may set it.
</blockquote>
<hr>
<h2>lws_get_context - Allow geting lws_context from a Websocket connection instance</h2>
<i>LWS_EXTERN struct lws_context *</i>
<b>lws_get_context</b>
(<i>const struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Websocket connection instance
</dl>
<h3>Description</h3>
<blockquote>
<p>
With this function, users can access context in the callback function.
Otherwise users may have to declare context as a global variable.
</blockquote>
<hr>
<h2>lws_parse_uri - </h2>
<i>LWS_EXTERN int</i>
<b>lws_parse_uri</b>
(<i>char *</i> <b>p</b>,
<i>const char **</i> <b>prot</b>,
<i>const char **</i> <b>ads</b>,
<i>int *</i> <b>port</b>,
<i>const char **</i> <b>path</b>)
<h3>Arguments</h3>
<dl>
<dt><b>p</b>
<dd>incoming uri string.. will get written to
<dt><b>prot</b>
<dd>result pointer for protocol part (https://)
<dt><b>ads</b>
<dd>result pointer for address part
<dt><b>port</b>
<dd>result pointer for port part
<dt><b>path</b>
<dd>result pointer for path part
</dl>
<h3>Description</h3>
<blockquote>
Notice it does so by dropping '\0' into input string
and the leading / on the path is consequently lost
</blockquote>
<hr>
<h2>lws_sql_purify - like strncpy but with escaping for sql quotes</h2>
<i>LWS_EXTERN const char *</i>
<b>lws_sql_purify</b>
(<i>char *</i> <b>escaped</b>,
<i>const char *</i> <b>string</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>escaped</b>
<dd>output buffer
<dt><b>string</b>
<dd>input buffer ('/0' terminated)
<dt><b>len</b>
<dd>output buffer max length
</dl>
<h3>Description</h3>
<blockquote>
Because escaping expands the output string, it's not
possible to do it in-place, ie, with escaped == string
</blockquote>
<hr>
<h2>lws_urlencode - like strncpy but with urlencoding</h2>
<i>LWS_EXTERN const char *</i>
<b>lws_urlencode</b>
(<i>char *</i> <b>escaped</b>,
<i>const char *</i> <b>string</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>escaped</b>
<dd>output buffer
<dt><b>string</b>
<dd>input buffer ('/0' terminated)
<dt><b>len</b>
<dd>output buffer max length
</dl>
<h3>Description</h3>
<blockquote>
Because urlencoding expands the output string, it's not
possible to do it in-place, ie, with escaped == string
</blockquote>
<hr>
<h2>lws_urldecode - like strncpy but with urldecoding</h2>
<i>LWS_EXTERN int</i>
<b>lws_urldecode</b>
(<i>char *</i> <b>string</b>,
<i>const char *</i> <b>escaped</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>string</b>
<dd>output buffer
<dt><b>escaped</b>
<dd>input buffer ('\0' terminated)
<dt><b>len</b>
<dd>output buffer max length
</dl>
<h3>Description</h3>
<blockquote>
This is only useful for '\0' terminated strings
<p>
Since urldecoding only shrinks the output string, it is possible to
do it in-place, ie, string == escaped
</blockquote>
<hr>
<h2>lws_urldecode_spa_create - create urldecode parser</h2>
<i>LWS_EXTERN struct lws_urldecode_stateful_param_array *</i>
<b>lws_urldecode_spa_create</b>
(<i>const char *const *</i> <b>param_names</b>,
<i>int</i> <b>count_params</b>,
<i>int</i> <b>max_storage</b>,
<i>lws_urldecode_stateful_cb</i> <b>opt_cb</b>,
<i>void *</i> <b>opt_data</b>)
<h3>Arguments</h3>
<dl>
<dt><b>param_names</b>
<dd>array of form parameter names, like "username"
<dt><b>count_params</b>
<dd>count of param_names
<dt><b>max_storage</b>
<dd>total amount of form parameter values we can store
<dt><b>opt_cb</b>
<dd>NULL, or callback to filter data. Needed for file transfer case
<dt><b>opt_data</b>
<dd>NULL, or user pointer provided to opt_cb.
</dl>
<h3>Description</h3>
<blockquote>
Creates a urldecode parser and initializes it.
<p>
<tt><b>opt_cb</b></tt> can be NULL if you just want normal name=value parsing, however
if one or more entries in your form are bulk data (file transfer), you
can provide this callback and filter on the name callback parameter to
treat that urldecoded data separately. The callback should return -1
in case of fatal error, 1 if it handled the data itself and 0 if it
wants the data to be handled as name=value.
</blockquote>
<hr>
<h2>lws_urldecode_spa_process - parses a chunk of input data</h2>
<i>LWS_EXTERN int</i>
<b>lws_urldecode_spa_process</b>
(<i>struct lws_urldecode_stateful_param_array *</i> <b>ludspa</b>,
<i>const char *</i> <b>in</b>,
<i>int</i> <b>len</b>)
<h3>Arguments</h3>
<dl>
<dt><b>ludspa</b>
<dd>the parser object previously created
<dt><b>in</b>
<dd>incoming, urlencoded data
<dt><b>len</b>
<dd>count of bytes valid at <tt><b>in</b></tt>
</dl>
<hr>
<h2>lws_urldecode_spa_get_length - return length of parameter value</h2>
<i>LWS_EXTERN int</i>
<b>lws_urldecode_spa_get_length</b>
(<i>struct lws_urldecode_stateful_param_array *</i> <b>ludspa</b>,
<i>int</i> <b>n</b>)
<h3>Arguments</h3>
<dl>
<dt><b>ludspa</b>
<dd>the parser object previously created
<dt><b>n</b>
<dd>parameter ordinal to return length of value for
</dl>
<hr>
<h2>lws_urldecode_spa_get_string - return pointer to parameter value</h2>
<i>LWS_EXTERN const char *</i>
<b>lws_urldecode_spa_get_string</b>
(<i>struct lws_urldecode_stateful_param_array *</i> <b>ludspa</b>,
<i>int</i> <b>n</b>)
<h3>Arguments</h3>
<dl>
<dt><b>ludspa</b>
<dd>the parser object previously created
<dt><b>n</b>
<dd>parameter ordinal to return pointer to value for
</dl>
<hr>
<h2>lws_urldecode_spa_finalize - indicate incoming data completed</h2>
<i>LWS_EXTERN int</i>
<b>lws_urldecode_spa_finalize</b>
(<i>struct lws_urldecode_stateful_param_array *</i> <b>spa</b>)
<h3>Arguments</h3>
<dl>
</dl>
<hr>
<h2>lws_urldecode_spa_destroy - destroy parser object</h2>
<i>LWS_EXTERN int</i>
<b>lws_urldecode_spa_destroy</b>
(<i>struct lws_urldecode_stateful_param_array *</i> <b>spa</b>)
<h3>Arguments</h3>
<dl>
</dl>
<hr>
<h2>lws_cgi - connected cgi process</h2>
<i>LWS_EXTERN int</i>
<b>lws_cgi</b>
(<i>struct lws *</i> <b>wsi</b>,
<i>const char *const *</i> <b>exec_array</b>,
<i>int</i> <b>script_uri_path_len</b>,
<i>int</i> <b>timeout_secs</b>,
<i>const struct lws_protocol_vhost_options *</i> <b>mp_cgienv</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>connection to own the process
<dt><b>exec_array</b>
<dd>array of "exec-name" "arg1" ... "argn" NULL
</dl>
<hr>
<h2>lws_cgi_write_split_stdout_headers - </h2>
<i>LWS_EXTERN int</i>
<b>lws_cgi_write_split_stdout_headers</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>connection to own the process
</dl>
<hr>
<h2>lws_cgi_kill - </h2>
<i>LWS_EXTERN int</i>
<b>lws_cgi_kill</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>connection to own the process
</dl>
<hr>
<h2>lws_cancel_service - Cancel servicing of pending websocket activity</h2>
<i>void</i>
<b>lws_cancel_service</b>
(<i>struct lws_context *</i> <b>context</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
</dl>
<h3>Description</h3>
<blockquote>
This function let a call to <b>lws_service</b> waiting for a timeout
immediately return.
<p>
There is no <b>poll</b> in MBED3, he will fire callbacks when he feels like
it.
</blockquote>
<hr>
<h2>lws_cancel_service_pt - Cancel servicing of pending socket activity on one thread</h2>
<i>void</i>
<b>lws_cancel_service_pt</b>
(<i>struct lws *</i> <b>wsi</b>)
<h3>Arguments</h3>
<dl>
<dt><b>wsi</b>
<dd>Cancel service on the thread this wsi is serviced by
</dl>
<h3>Description</h3>
<blockquote>
This function let a call to <b>lws_service</b> waiting for a timeout
immediately return.
</blockquote>
<hr>
<h2>lws_cancel_service - Cancel ALL servicing of pending socket activity</h2>
<i>void</i>
<b>lws_cancel_service</b>
(<i>struct lws_context *</i> <b>context</b>)
<h3>Arguments</h3>
<dl>
<dt><b>context</b>
<dd>Websocket context
</dl>
<h3>Description</h3>