Search completed in 2.26 seconds.
8 results for "keepalive":
Compiling a New C/C++ Module to WebAssembly - WebAssembly
emscripten requires a large variety of javascript "glue" code to handle memory allocation, memory leaks, and a host of other problems calling a custom function defined in c if you have a function defined in your c code that you want to call as needed from javascript, you can do this using the emscripten ccall() function, and the emscripten_
keepalive declaration (which adds your functions to the exported functions list (see why do functions in my c/c++ source code vanish when i compile to javascript, and/or i get no functions to process?)).
... to start with, save the following code as hello3.c in a new directory: #include <stdio.h> #include <emscripten/emscripten.h> int main(int argc, char ** argv) { printf("hello world\n"); } #ifdef __cplusplus extern "c" { #endif void emscripten_
keepalive myfunction(int argc, char ** argv) { printf("myfunction called\n"); } #ifdef __cplusplus } #endif by default, emscripten-generated code always just calls the main() function, and other functions are eliminated as dead code.
... putting emscripten_
keepalive before a function name stops this from happening.
... you also need to import the emscripten.h library to use emscripten_
keepalive.
Compiling an Existing C Module to WebAssembly - WebAssembly
$ git clone https://github.com/webmproject/libwebp to start off simple, expose webpgetencoderversion() from encode.h to javascript by writing a c file called webp.c: #include "emscripten.h" #include "src/webp/encode.h" emscripten_
keepalive int version() { return webpgetencoderversion(); } this is a good simple program to test whether you can get the source code of libwebp to compile, as it doesn't require any parameters or complex data structures to invoke this function.
...for that, you need to expose two additional functions — one that allocates memory for the image inside wasm and one that frees it up again: #include <stdlib.h> // required for malloc definition emscripten_
keepalive uint8_t* create_buffer(int width, int height) { return malloc(width * height * 4 * sizeof(uint8_t)); } emscripten_
keepalive void destroy_buffer(uint8_t* p) { free(p); } the create_buffer() function allocates a buffer for the rgba image — hence 4 bytes per pixel.
...but this is a fair shortuct for keeping things simple: int result[2]; emscripten_
keepalive void encode(uint8_t* img_in, int width, int height, float quality) { uint8_t* img_out; size_t size; size = webpencodergba(img_in, width, height, width * 4, quality, &img_out); result[0] = (int)img_out; result[1] = size; } emscripten_
keepalive void free_result(uint8_t* result) { webpfree(result); } emscripten_
keepalive int get_result_pointer() { return result[0]; } emscripten_ke...
PRSockOption
syntax #include <prio.h> typedef enum prsockoption { pr_sockopt_nonblocking, pr_sockopt_linger, pr_sockopt_reuseaddr, pr_sockopt_
keepalive, pr_sockopt_recvbuffersize, pr_sockopt_sendbuffersize, pr_sockopt_iptimetolive, pr_sockopt_iptypeofservice, pr_sockopt_addmember, pr_sockopt_dropmember, pr_sockopt_mcastinterface, pr_sockopt_mcasttimetolive, pr_sockopt_mcastloopback, pr_sockopt_nodelay, pr_sockopt_maxsegment, pr_sockopt_last } prsockoption; enumerators the enumeration has the following enumerators: pr_sockopt_nonblocking nonblocking i/o.
... pr_sockopt_
keepalive periodically test whether connection is still alive.
Synchronous and asynchronous requests - Web APIs
you should consider using the fetch() api with the
keepalive flag.
... when fetch with
keepalive isn't available, you can consider using the navigator.sendbeacon() api, which can support these use cases while typically delivering a good ux.
HTTP delegation
nss may choose to repeatedly call a "network connection keep alive" function (sec_httpserver_
keepalivesessionfcn) on the server session object, giving application code a chance to do whatever is required.
HTTP delegation
nss may choose to repeatedly call a "network connection keep alive" function (sec_httpserver_
keepalivesessionfcn) on the server session object, giving application code a chance to do whatever is required.
PerformanceEventTiming - Web APIs
(navigator.sendbeacon && navigator.sendbeacon('/analytics', body)) || fetch('/analytics', {body, method: 'post',
keepalive: true}); } // use a try/catch instead of feature detecting `first-input` // support, since some browsers throw when using the new `type` option.