![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Functions | |
LWS_VISIBLE LWS_EXTERN struct lws * | lws_adopt_socket (struct lws_context *context, lws_sockfd_type accept_fd) |
LWS_VISIBLE LWS_EXTERN struct lws * | lws_adopt_socket_vhost (struct lws_vhost *vh, lws_sockfd_type accept_fd) |
LWS_VISIBLE LWS_EXTERN struct lws * | lws_adopt_socket_readbuf (struct lws_context *context, lws_sockfd_type accept_fd, const char *readbuf, size_t len) |
LWS_VISIBLE LWS_EXTERN struct lws * | lws_adopt_socket_vhost_readbuf (struct lws_vhost *vhost, lws_sockfd_type accept_fd, const char *readbuf, size_t len) |
When integrating with an external app with its own event loop, these can be used to accept connections from someone else's listening socket.
When using lws own event loop, these are not needed.
LWS_VISIBLE LWS_EXTERN struct lws* lws_adopt_socket | ( | struct lws_context * | context, |
lws_sockfd_type | accept_fd | ||
) |
#include <lib/libwebsockets.h>
lws_adopt_socket() - adopt foreign socket as if listen socket accepted it for the default vhost of context.
context | lws context |
accept_fd | fd of already-accepted socket to adopt |
Either returns new wsi bound to accept_fd, or closes accept_fd and returns NULL, having cleaned up any new wsi pieces.
LWS adopts the socket in http serving mode, it's ready to accept an upgrade to ws or just serve http.
LWS_VISIBLE LWS_EXTERN struct lws* lws_adopt_socket_readbuf | ( | struct lws_context * | context, |
lws_sockfd_type | accept_fd, | ||
const char * | readbuf, | ||
size_t | len | ||
) |
#include <lib/libwebsockets.h>
lws_adopt_socket_readbuf() - adopt foreign socket and first rx as if listen socket accepted it for the default vhost of context.
context | lws context |
accept_fd | fd of already-accepted socket to adopt |
readbuf | NULL or pointer to data that must be drained before reading from accept_fd |
len | The length of the data held at |
readbuf | Either returns new wsi bound to accept_fd, or closes accept_fd and returns NULL, having cleaned up any new wsi pieces. |
LWS adopts the socket in http serving mode, it's ready to accept an upgrade to ws or just serve http.
If your external code did not already read from the socket, you can use lws_adopt_socket() instead.
This api is guaranteed to use the data at
readbuf | first, before reading from the socket. |
readbuf is limited to the size of the ah rx buf, currently 2048 bytes.
LWS_VISIBLE LWS_EXTERN struct lws* lws_adopt_socket_vhost | ( | struct lws_vhost * | vh, |
lws_sockfd_type | accept_fd | ||
) |
#include <lib/libwebsockets.h>
lws_adopt_socket_vhost() - adopt foreign socket as if listen socket accepted it for vhost
vhost | lws vhost |
accept_fd | fd of already-accepted socket to adopt |
Either returns new wsi bound to accept_fd, or closes accept_fd and returns NULL, having cleaned up any new wsi pieces.
LWS adopts the socket in http serving mode, it's ready to accept an upgrade to ws or just serve http.
LWS_VISIBLE LWS_EXTERN struct lws* lws_adopt_socket_vhost_readbuf | ( | struct lws_vhost * | vhost, |
lws_sockfd_type | accept_fd, | ||
const char * | readbuf, | ||
size_t | len | ||
) |
#include <lib/libwebsockets.h>
lws_adopt_socket_vhost_readbuf() - adopt foreign socket and first rx as if listen socket accepted it for vhost.
vhost | lws vhost |
accept_fd | fd of already-accepted socket to adopt |
readbuf | NULL or pointer to data that must be drained before reading from accept_fd |
len | The length of the data held at |
readbuf | Either returns new wsi bound to accept_fd, or closes accept_fd and returns NULL, having cleaned up any new wsi pieces. |
LWS adopts the socket in http serving mode, it's ready to accept an upgrade to ws or just serve http.
If your external code did not already read from the socket, you can use lws_adopt_socket() instead.
This api is guaranteed to use the data at
readbuf | first, before reading from the socket. |
readbuf is limited to the size of the ah rx buf, currently 2048 bytes.