xref: /aosp_15_r20/external/libwebsockets/READMEs/README.lws_conmon.md (revision 1c60b9aca93fdbc9b5f19b2d2194c91294b22281)
1*1c60b9acSAndroid Build Coastguard Worker## `lws_conmon` apis
2*1c60b9acSAndroid Build Coastguard Worker
3*1c60b9acSAndroid Build Coastguard Worker`LWS_WITH_CONMON` build option enables `lws_conmon` apis for user code... these add
4*1c60b9acSAndroid Build Coastguard Workersome staticistic and information to client connections that can use useful for devices
5*1c60b9acSAndroid Build Coastguard Workerto introspect how the connection to their servers is actually performing.
6*1c60b9acSAndroid Build Coastguard Worker
7*1c60b9acSAndroid Build Coastguard WorkerThe public apis can be found in `libwebsockets/lws-conmon.h`.
8*1c60b9acSAndroid Build Coastguard Worker
9*1c60b9acSAndroid Build Coastguard WorkerA struct is provided that describes
10*1c60b9acSAndroid Build Coastguard Worker
11*1c60b9acSAndroid Build Coastguard Worker - the peer sockaddr the wsi actually connected to, if any
12*1c60b9acSAndroid Build Coastguard Worker
13*1c60b9acSAndroid Build Coastguard Worker - a deep copy of the aggregate DNS results (struct addrinfo list) that the
14*1c60b9acSAndroid Build Coastguard Worker   client had access to for the peer
15*1c60b9acSAndroid Build Coastguard Worker
16*1c60b9acSAndroid Build Coastguard Worker - the number of us dns lookup took
17*1c60b9acSAndroid Build Coastguard Worker
18*1c60b9acSAndroid Build Coastguard Worker - the number of us the socket connection took
19*1c60b9acSAndroid Build Coastguard Worker
20*1c60b9acSAndroid Build Coastguard Worker - the number of us the tls link establishment took
21*1c60b9acSAndroid Build Coastguard Worker
22*1c60b9acSAndroid Build Coastguard Worker - the number of us from the transaction request to the first response, if
23*1c60b9acSAndroid Build Coastguard Worker   the protocol has a transaction concept
24*1c60b9acSAndroid Build Coastguard Worker
25*1c60b9acSAndroid Build Coastguard WorkerBecause the user code may want to hold on to the DNS list for longer than the
26*1c60b9acSAndroid Build Coastguard Workerlife of the wsi that originated it, the `lws_conmon_wsi_take()` api allows
27*1c60b9acSAndroid Build Coastguard Workerthe ownership of the allocated list to be transferred to the user code (as
28*1c60b9acSAndroid Build Coastguard Workerwell as copying data out into the user's struct so it no longer has any
29*1c60b9acSAndroid Build Coastguard Workerdependency on wsi lifetime either).  The DNS list copy in the struct must be
30*1c60b9acSAndroid Build Coastguard Workerreleased at some point by calling `lws_conmon_release()`, but that
31*1c60b9acSAndroid Build Coastguard Workercan be at any time afterwards.
32*1c60b9acSAndroid Build Coastguard Worker
33*1c60b9acSAndroid Build Coastguard WorkerThe lws-minimal-http-client example shows how user code can use the apis, build
34*1c60b9acSAndroid Build Coastguard Workerlws with the `LWS_WITH_CONMON` cmake option and run with `--conmon` to get a
35*1c60b9acSAndroid Build Coastguard Workerdump of the collected information.
36*1c60b9acSAndroid Build Coastguard Worker
37