diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index e2d7731d..bcde2acb 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -819,6 +819,15 @@ libwebsocket_service_timeout_check(struct libwebsocket_context *context, * * The one call deals with all "service" that might happen on a socket * including listen accepts, http files as well as websocket protocol. + * + * If a pollfd says it has something, you can just pass it to + * libwebsocket_serice_fd() whether it is a socket handled by lws or not. + * If it sees it is a lws socket, the traffic will be handled and + * pollfd->revents will be zeroed now. + * + * If the socket is foreign to lws, it leaves revents alone. So you can + * see if you should service yourself by checking the pollfd revents + * after letting lws try to service it. */ int diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index e4ad60bb..7c8e1c18 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -1,88 +1,40 @@ -

libwebsocket_client_connect - Connect to another websocket server

-struct libwebsocket * -libwebsocket_client_connect -(struct libwebsocket_context * context, -const char * address, -int port, -int ssl_connection, -const char * path, -const char * host, -const char * origin, -const char * protocol, -int ietf_version_or_minus_one) +

lws_frame_is_binary -

+int +lws_frame_is_binary +(struct libwebsocket * wsi)

Arguments

-
context -
Websocket context -
address -
Remote server address, eg, "myserver.com" -
port -
Port to connect to on the remote server, eg, 80 -
ssl_connection -
0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self -signed certs -
path -
Websocket path on server -
host -
Hostname on server -
origin -
Socket origin name -
protocol -
Comma-separated list of protocols being asked for from -the server, or just one. The server will pick the one it -likes best. -
ietf_version_or_minus_one -
-1 to ask to connect using the default, latest -protocol supported, or the specific protocol ordinal +
wsi +
the connection we are inquiring about

Description

-This function creates a connection to a remote server +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.

-

libwebsocket_client_connect_extended - Connect to another websocket server

-struct libwebsocket * -libwebsocket_client_connect_extended -(struct libwebsocket_context * context, -const char * address, -int port, -int ssl_connection, -const char * path, -const char * host, -const char * origin, -const char * protocol, -int ietf_version_or_minus_one, -void * userdata) +

libwebsockets_remaining_packet_payload - Bytes to come before "overall" rx packet is complete

+size_t +libwebsockets_remaining_packet_payload +(struct libwebsocket * wsi)

Arguments

-
context -
Websocket context -
address -
Remote server address, eg, "myserver.com" -
port -
Port to connect to on the remote server, eg, 80 -
ssl_connection -
0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self -signed certs -
path -
Websocket path on server -
host -
Hostname on server -
origin -
Socket origin name -
protocol -
Comma-separated list of protocols being asked for from -the server, or just one. The server will pick the one it -likes best. -
ietf_version_or_minus_one -
-1 to ask to connect using the default, latest -protocol supported, or the specific protocol ordinal -
userdata -
Pre-allocated user data +
wsi +
Websocket instance (available from user callback)

Description

-This function creates a connection to a remote server +This function is intended to be called from the callback if the +user code is interested in "complete packets" from the client. +libwebsockets just passes through payload as it comes and issues a buffer +additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE +callback handler can use this API to find out if the buffer it has just +been given is the last piece of a "complete packet" from the client -- +when that is the case libwebsockets_remaining_packet_payload will return +0. +

+Many protocols won't care becuse their packets are always small.


lws_get_library_version -

@@ -158,6 +110,15 @@ struct libwebsocket.

The one call deals with all "service" that might happen on a socket including listen accepts, http files as well as websocket protocol. +

+If a pollfd says it has something, you can just pass it to +libwebsocket_serice_fd whether it is a socket handled by lws or not. +If it sees it is a lws socket, the traffic will be handled and +pollfd->revents will be zeroed now. +

+If the socket is foreign to lws, it leaves revents alone. So you can +see if you should service yourself by checking the pollfd revents +after letting lws try to service it.


libwebsocket_context_destroy - Destroy the websocket context

@@ -475,43 +436,91 @@ Returning <0 indicates error and the wsi should be closed. Returning the wsi should be left alone.
-

lws_frame_is_binary -

-int -lws_frame_is_binary -(struct libwebsocket * wsi) +

libwebsocket_client_connect - Connect to another websocket server

+struct libwebsocket * +libwebsocket_client_connect +(struct libwebsocket_context * context, +const char * address, +int port, +int ssl_connection, +const char * path, +const char * host, +const char * origin, +const char * protocol, +int ietf_version_or_minus_one)

Arguments

-
wsi -
the connection we are inquiring about +
context +
Websocket context +
address +
Remote server address, eg, "myserver.com" +
port +
Port to connect to on the remote server, eg, 80 +
ssl_connection +
0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self +signed certs +
path +
Websocket path on server +
host +
Hostname on server +
origin +
Socket origin name +
protocol +
Comma-separated list of protocols being asked for from +the server, or just one. The server will pick the one it +likes best. +
ietf_version_or_minus_one +
-1 to ask to connect using the default, latest +protocol supported, or the specific protocol ordinal

Description

-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. +This function creates a connection to a remote server

-

libwebsockets_remaining_packet_payload - Bytes to come before "overall" rx packet is complete

-size_t -libwebsockets_remaining_packet_payload -(struct libwebsocket * wsi) +

libwebsocket_client_connect_extended - Connect to another websocket server

+struct libwebsocket * +libwebsocket_client_connect_extended +(struct libwebsocket_context * context, +const char * address, +int port, +int ssl_connection, +const char * path, +const char * host, +const char * origin, +const char * protocol, +int ietf_version_or_minus_one, +void * userdata)

Arguments

-
wsi -
Websocket instance (available from user callback) +
context +
Websocket context +
address +
Remote server address, eg, "myserver.com" +
port +
Port to connect to on the remote server, eg, 80 +
ssl_connection +
0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self +signed certs +
path +
Websocket path on server +
host +
Hostname on server +
origin +
Socket origin name +
protocol +
Comma-separated list of protocols being asked for from +the server, or just one. The server will pick the one it +likes best. +
ietf_version_or_minus_one +
-1 to ask to connect using the default, latest +protocol supported, or the specific protocol ordinal +
userdata +
Pre-allocated user data

Description

-This function is intended to be called from the callback if the -user code is interested in "complete packets" from the client. -libwebsockets just passes through payload as it comes and issues a buffer -additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE -callback handler can use this API to find out if the buffer it has just -been given is the last piece of a "complete packet" from the client -- -when that is the case libwebsockets_remaining_packet_payload will return -0. -

-Many protocols won't care becuse their packets are always small. +This function creates a connection to a remote server


callback - User server actions