![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Functions | |
LWS_VISIBLE LWS_EXTERN int | lws_snprintf (char *str, size_t size, const char *format,...) LWS_FORMAT(3) |
LWS_VISIBLE LWS_EXTERN int | lws_get_random (struct lws_context *context, void *buf, int len) |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | lws_daemonize (const char *_lock_path) |
LWS_VISIBLE LWS_EXTERN const char *LWS_WARN_UNUSED_RESULT | lws_get_library_version (void) |
LWS_VISIBLE LWS_EXTERN void * | lws_wsi_user (struct lws *wsi) |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | lws_parse_uri (char *p, const char **prot, const char **ads, int *port, const char **path) |
LWS_VISIBLE LWS_EXTERN unsigned long | lws_now_secs (void) |
LWS_VISIBLE LWS_EXTERN struct lws_context *LWS_WARN_UNUSED_RESULT | lws_get_context (const struct lws *wsi) |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | lws_get_count_threads (struct lws_context *context) |
LWS_VISIBLE LWS_EXTERN struct lws *LWS_WARN_UNUSED_RESULT | lws_get_parent (const struct lws *wsi) |
LWS_VISIBLE LWS_EXTERN struct lws *LWS_WARN_UNUSED_RESULT | lws_get_child (const struct lws *wsi) |
LWS_VISIBLE LWS_EXTERN int | lws_read (struct lws *wsi, unsigned char *buf, size_t len) |
LWS_VISIBLE LWS_EXTERN void | lws_set_allocator (void *(*realloc)(void *ptr, size_t size)) |
Various APIs outside of other categories
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_daemonize | ( | const char * | _lock_path | ) |
#include <lib/libwebsockets.h>
lws_daemonize(): fill a buffer with platform random data
_lock_path | the filepath to write the lock file |
Spawn lws as a background process, taking care of various things
LWS_VISIBLE LWS_EXTERN struct lws* LWS_WARN_UNUSED_RESULT lws_get_child | ( | const struct lws * | wsi | ) |
#include <lib/libwebsockets.h>
lws_get_child() - get child wsi or NULL
wsi | lws connection |
Allows you to find a related wsi from the parent wsi.
LWS_VISIBLE LWS_EXTERN struct lws_context* LWS_WARN_UNUSED_RESULT lws_get_context | ( | const struct lws * | wsi | ) |
#include <lib/libwebsockets.h>
lws_get_context - Allow geting lws_context from a Websocket connection instance
With this function, users can access context in the callback function. Otherwise users may have to declare context as a global variable.
wsi | Websocket connection instance |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_get_count_threads | ( | struct lws_context * | context | ) |
#include <lib/libwebsockets.h>
lws_get_count_threads(): how many service threads the context uses
context | the lws context |
By default this is always 1, if you asked for more than lws can handle it will clip the number of threads. So you can use this to find out how many threads are actually in use.
LWS_VISIBLE LWS_EXTERN const char* LWS_WARN_UNUSED_RESULT lws_get_library_version | ( | void | ) |
#include <lib/libwebsockets.h>
lws_get_library_version(): return string describing the version of lws
On unix, also includes the git describe
LWS_VISIBLE LWS_EXTERN struct lws* LWS_WARN_UNUSED_RESULT lws_get_parent | ( | const struct lws * | wsi | ) |
#include <lib/libwebsockets.h>
lws_get_parent() - get parent wsi or NULL
wsi | lws connection |
Specialized wsi like cgi stdin/out/err are associated to a parent wsi, this allows you to get their parent.
LWS_VISIBLE LWS_EXTERN int lws_get_random | ( | struct lws_context * | context, |
void * | buf, | ||
int | len | ||
) |
#include <lib/libwebsockets.h>
lws_get_random(): fill a buffer with platform random data
context | the lws context |
buf | buffer to fill |
len | how much to fill |
This is intended to be called from the LWS_CALLBACK_RECEIVE callback if it's interested to see if the frame it's dealing with was sent in binary mode.
LWS_VISIBLE LWS_EXTERN unsigned long lws_now_secs | ( | void | ) |
#include <lib/libwebsockets.h>
lws_now_secs(): return seconds since 1970-1-1
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_parse_uri | ( | char * | p, |
const char ** | prot, | ||
const char ** | ads, | ||
int * | port, | ||
const char ** | path | ||
) |
#include <lib/libwebsockets.h>
lws_parse_uri: cut up prot:/ads:port/path into pieces Notice it does so by dropping '\0' into input string and the leading / on the path is consequently lost
p | incoming uri string.. will get written to |
prot | result pointer for protocol part (https://) |
ads | result pointer for address part |
port | result pointer for port part |
path | result pointer for path part |
LWS_VISIBLE LWS_EXTERN void lws_set_allocator | ( | void *(*)(void *ptr, size_t size) | realloc | ) |
#include <lib/libwebsockets.h>
lws_set_allocator() - custom allocator support
realloc | Allows you to replace the allocator (and deallocator) used by lws |
LWS_VISIBLE LWS_EXTERN int lws_snprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
... | |||
) |
#include <lib/libwebsockets.h>
lws_snprintf(): snprintf that truncates the returned length too
str | destination buffer |
size | bytes left in destination buffer |
format | format string |
... | args for format |
This lets you correctly truncate buffers by concatenating lengths, if you reach the limit the reported length doesn't exceed the limit.
LWS_VISIBLE LWS_EXTERN void* lws_wsi_user | ( | struct lws * | wsi | ) |
#include <lib/libwebsockets.h>
lws_wsi_user() - get the user data associated with the connection
wsi | lws connection |
Not normally needed since it's passed into the callback