==1811411== Memcheck, a memory error detector ==1811411== Copyright (C) 2002-2026, and GNU GPL'd, by Julian Seward et al. ==1811411== Using Valgrind-3.27.1 and LibVEX; rerun with -h for copyright info ==1811411== Command: /data/localhost/ripley/R/R-devel-vg/bin/exec/R --vanilla ==1811411== R Under development (unstable) (2026-07-29 r90317) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "nanonext" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('nanonext') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("call_aio") > ### * call_aio > > flush(stderr()); flush(stdout()) > > ### Name: call_aio > ### Title: Call the Value of an Asynchronous Aio Operation > ### Aliases: call_aio call_aio_ > > ### ** Examples > > s1 <- socket("pair", listen = "inproc://nanonext") > s2 <- socket("pair", dial = "inproc://nanonext") > > res <- send_aio(s1, data.frame(a = 1, b = 2), timeout = 100) > res < sendAio | $result > > call_aio(res) > res$result [1] 0 > > msg <- recv_aio(s2, timeout = 100) > msg < recvAio | $data > > call_aio_(msg)$data a b 1 1 2 > > close(s1) > close(s2) > > > > > cleanEx() > nameEx("collect_aio") > ### * collect_aio > > flush(stderr()); flush(stdout()) > > ### Name: collect_aio > ### Title: Collect Data of an Aio or List of Aios > ### Aliases: collect_aio collect_aio_ > > ### ** Examples > > s1 <- socket("pair", listen = "inproc://nanonext") > s2 <- socket("pair", dial = "inproc://nanonext") > > res <- send_aio(s1, data.frame(a = 1, b = 2), timeout = 100) > collect_aio(res) [1] 0 > > msg <- recv_aio(s2, timeout = 100) > collect_aio_(msg) a b 1 1 2 > > msg[] a b 1 1 2 > > close(s1) > close(s2) > > > > > cleanEx() > nameEx("context") > ### * context > > flush(stderr()); flush(stdout()) > > ### Name: context > ### Title: Open Context > ### Aliases: context > > ### ** Examples > > s <- socket("req", listen = "inproc://nanonext") > ctx <- context(s) > ctx < nanoContext > - id: 1 - socket: 5 - state: opened - protocol: req > close(ctx) > close(s) > > n <- nano("req", listen = "inproc://nanonext") > n$context_open() > n$context < nanoContext > - id: 2 - socket: 6 - state: opened - protocol: req > n$context_open() > n$context < nanoContext > - id: 3 - socket: 6 - state: opened - protocol: req > n$context_close() [1] 0 > n$close() > > > > > cleanEx() > nameEx("cv") > ### * cv > > flush(stderr()); flush(stdout()) > > ### Name: cv > ### Title: Condition Variables > ### Aliases: cv wait wait_ until until_ cv_value cv_reset cv_signal > > ### ** Examples > > cv <- cv() > > ## Not run: > ##D wait(cv) # would block until the cv is signalled > ##D wait_(cv) # would block until the cv is signalled or interrupted > ## End(Not run) > > until(cv, 10L) > until_(cv, 10L) > > cv_value(cv) [1] 0 > > cv_reset(cv) > > cv_value(cv) [1] 0 > cv_signal(cv) > cv_value(cv) [1] 1 > > > > > cleanEx() > nameEx("device_aio") > ### * device_aio > > flush(stderr()); flush(stdout()) > > ### Name: device_aio > ### Title: Device (Async) > ### Aliases: device_aio > > ### ** Examples > > s1 <- socket("pair", listen = "inproc://device1", raw = TRUE) > s2 <- socket("pair", listen = "inproc://device2", raw = TRUE) > > dev <- device_aio(s1, s2) > dev$result 'unresolved' logi NA > > stop_aio(dev) > dev$result 'errorValue' int 20 | Operation canceled > close(s1) > close(s2) > > > > > cleanEx() > nameEx("dial") > ### * dial > > flush(stderr()); flush(stdout()) > > ### Name: dial > ### Title: Dial an Address from a Socket > ### Aliases: dial > > ### ** Examples > > socket <- socket("rep") > dial(socket, url = "inproc://nanodial", autostart = FALSE) > socket$dialer [[1]] < nanoDialer > - id: 3 - socket: 9 - state: not started - url: inproc://nanodial > start(socket$dialer[[1]]) > socket$dialer [[1]] < nanoDialer > - id: 3 - socket: 9 - state: started - url: inproc://nanodial > close(socket$dialer[[1]]) > close(socket) > > nano <- nano("bus") > nano$dial(url = "inproc://nanodial", autostart = FALSE) > nano$dialer [[1]] < nanoDialer > - id: 4 - socket: 10 - state: not started - url: inproc://nanodial > nano$dialer_start() > nano$dialer [[1]] < nanoDialer > - id: 4 - socket: 10 - state: started - url: inproc://nanodial > close(nano$dialer[[1]]) > nano$close() > > > > > cleanEx() > nameEx("format_sse") > ### * format_sse > > flush(stderr()); flush(stdout()) > > ### Name: format_sse > ### Title: Format Server-Sent Event > ### Aliases: format_sse > > ### ** Examples > > format_sse(data = "Hello") [1] "data: Hello\n\n" > #> "data: Hello\n\n" > > format_sse(data = "Hello", event = "greeting") [1] "event: greeting\ndata: Hello\n\n" > #> "event: greeting\ndata: Hello\n\n" > > format_sse(data = "Line 1\nLine 2") [1] "data: Line 1\ndata: Line 2\n\n" > #> "data: Line 1\ndata: Line 2\n\n" > > # Typical SSE endpoint setup > h <- handler_stream("/events", function(conn, req) { + conn$set_header("Content-Type", "text/event-stream") + conn$set_header("Cache-Control", "no-cache") + conn$set_header("X-Accel-Buffering", "no") + conn$send(format_sse(data = "connected", id = "1")) + }) > > > > > cleanEx() > nameEx("grapes-twiddle-greater-than-grapes") > ### * grapes-twiddle-greater-than-grapes > > flush(stderr()); flush(stdout()) > > ### Name: %~>% > ### Title: Signal Forwarder > ### Aliases: %~>% > > ### ** Examples > > cva <- cv(); cvb <- cv(); cv1 <- cv(); cv2 <- cv() > > cva %~>% cv1 %~>% cv2 > cvb %~>% cv2 > > cv_signal(cva) > cv_signal(cvb) > cv_value(cv1) [1] 1 > cv_value(cv2) [1] 2 > > > > > cleanEx() > nameEx("handler") > ### * handler > > flush(stderr()); flush(stdout()) > > ### Name: handler > ### Title: Create HTTP Handler > ### Aliases: handler > > ### ** Examples > > # Simple GET handler > h1 <- handler("/hello", function(req) { + list(status = 200L, body = "Hello!") + }) > > # POST handler that echoes the request body > h2 <- handler("/echo", function(req) { + list(status = 200L, body = req$body) + }, method = "POST") > > # Catch-all handler for a path prefix > h3 <- handler("/static", function(req) { + # Serve static files under /static/* + }, method = "*", prefix = TRUE) > > > > > cleanEx() > nameEx("handler_directory") > ### * handler_directory > > flush(stderr()); flush(stdout()) > > ### Name: handler_directory > ### Title: Create Static Directory Handler > ### Aliases: handler_directory > > ### ** Examples > > ## Don't show: > if (interactive()) withAutoprint({ # examplesIf + ## End(Don't show) + h <- handler_directory("/static", "www/assets") + ## Don't show: + }) # examplesIf > ## End(Don't show) > > > > cleanEx() > nameEx("handler_file") > ### * handler_file > > flush(stderr()); flush(stdout()) > > ### Name: handler_file > ### Title: Create Static File Handler > ### Aliases: handler_file > > ### ** Examples > > ## Don't show: > if (interactive()) withAutoprint({ # examplesIf + ## End(Don't show) + h <- handler_file("/favicon.ico", "~/favicon.ico") + ## Don't show: + }) # examplesIf > ## End(Don't show) > > > > cleanEx() > nameEx("handler_inline") > ### * handler_inline > > flush(stderr()); flush(stdout()) > > ### Name: handler_inline > ### Title: Create Inline Static Content Handler > ### Aliases: handler_inline > > ### ** Examples > > h1 <- handler_inline("/robots.txt", "User-agent: *\nDisallow:", + content_type = "text/plain") > h2 <- handler_inline("/health", '{"status":"ok"}', + content_type = "application/json") > > > > > cleanEx() > nameEx("handler_redirect") > ### * handler_redirect > > flush(stderr()); flush(stdout()) > > ### Name: handler_redirect > ### Title: Create HTTP Redirect Handler > ### Aliases: handler_redirect > > ### ** Examples > > # Permanent redirect > h1 <- handler_redirect("/old", "/new", status = 301L) > > # Redirect bare path to trailing slash > h2 <- handler_redirect("/app", "/app/") > > > > > cleanEx() > nameEx("handler_stream") > ### * handler_stream > > flush(stderr()); flush(stdout()) > > ### Name: handler_stream > ### Title: Create HTTP Streaming Handler > ### Aliases: handler_stream > > ### ** Examples > > # NDJSON streaming endpoint > h <- handler_stream("/stream", function(conn, req) { + conn$set_header("Content-Type", "application/x-ndjson") + conn$send('{"status":"connected"}\n') + }) > > # SSE endpoint with reconnection support > h <- handler_stream("/events", function(conn, req) { + conn$set_header("Content-Type", "text/event-stream") + conn$set_header("Cache-Control", "no-cache") + last_id <- req$headers["Last-Event-ID"] + # Resume from last_id if client is reconnecting + conn$send(format_sse(data = "connected", id = "1")) + }) > > # Long-lived streaming with broadcast triggered by POST > conns <- list() > handlers <- list( + handler_stream("/stream", + on_request = function(conn, req) { + conn$set_header("Content-Type", "application/x-ndjson") + conns[[as.character(conn$id)]] <<- conn + conn$send('{"status":"connected"}\n') + }, + on_close = function(conn) { + conns[[as.character(conn$id)]] <<- NULL + } + ), + # POST endpoint triggers broadcast to all streaming clients + handler("/broadcast", function(req) { + msg <- paste0('{"msg":"', rawToChar(req$body), '"}\n') + lapply(conns, function(c) c$send(msg)) + list(status = 200L, body = "sent") + }, method = "POST") + ) > > > > > cleanEx() > nameEx("handler_ws") > ### * handler_ws > > flush(stderr()); flush(stdout()) > > ### Name: handler_ws > ### Title: Create WebSocket Handler > ### Aliases: handler_ws > > ### ** Examples > > # Simple echo server > h <- handler_ws("/ws", function(ws, data) ws$send(data)) > > # With connection tracking > clients <- list() > h <- handler_ws( + "/chat", + on_message = function(ws, data) { + # Broadcast to all + for (client in clients) client$send(data) + }, + on_open = function(ws, req) { + clients[[as.character(ws$id)]] <<- ws + }, + on_close = function(ws) { + clients[[as.character(ws$id)]] <<- NULL + }, + textframes = TRUE + ) > > > > > cleanEx() > nameEx("http_server") > ### * http_server > > flush(stderr()); flush(stdout()) > > ### Name: http_server > ### Title: Create HTTP/WebSocket Server > ### Aliases: http_server > > ### ** Examples > > ## Don't show: > if (interactive() && requireNamespace("later", quietly = TRUE)) withAutoprint({ # examplesIf + ## End(Don't show) + # Simple HTTP server + server <- http_server( + url = "http://127.0.0.1:8080", + handlers = list( + handler("/", function(req) { + list(status = 200L, body = "Hello, World!") + }), + handler("/api/data", function(req) { + list( + status = 200L, + headers = c("Content-Type" = "application/json"), + body = '{"value": 42}' + ) + }) + ) + ) + server$start() + # Run event loop: repeat run_event_loop(1000) + server$close() + + # HTTP + WebSocket server + server <- http_server( + url = "http://127.0.0.1:8080", + handlers = list( + handler("/", function(req) { + list(status = 200L, body = "...") + }), + handler_ws("/ws", function(ws, data) { + ws$send(data) # Echo + }, textframes = TRUE) + ) + ) + + # Multiple WebSocket endpoints + server <- http_server( + url = "http://127.0.0.1:8080", + handlers = list( + handler_ws("/echo", function(ws, data) ws$send(data)), + handler_ws("/upper", function(ws, data) ws$send(toupper(data)), textframes = TRUE) + ) + ) + + # HTTPS server with self-signed certificate + cert <- write_cert(cn = "127.0.0.1") + cfg <- tls_config(server = cert$server) + server <- http_server( + url = "https://127.0.0.1:8443", + handlers = list( + handler("/", function(req) list(status = 200L, body = "Secure!")) + ), + tls = cfg + ) + server$start() + + # Send async request and run event loop + aio <- ncurl_aio( + "https://127.0.0.1:8443/", + tls = tls_config(client = cert$client), + timeout = 2000 + ) + while (unresolved(aio)) run_event_loop(1000) + + aio$status + aio$data + + server$close() + ## Don't show: + }) # examplesIf > ## End(Don't show) > > > > cleanEx() > nameEx("ip_addr") > ### * ip_addr > > flush(stderr()); flush(stdout()) > > ### Name: ip_addr > ### Title: IP Address > ### Aliases: ip_addr > > ### ** Examples > > ip_addr() eno1 "163.1.210.89" > > > > > cleanEx() > nameEx("is_aio") > ### * is_aio > > flush(stderr()); flush(stdout()) > > ### Name: is_aio > ### Title: Validators > ### Aliases: is_aio is_nano is_ncurl_session > > ### ** Examples > > nc <- call_aio(ncurl_aio("https://postman-echo.com/get", timeout = 1000L)) > is_aio(nc) [1] TRUE > > s <- socket() > is_nano(s) [1] TRUE > n <- nano() > is_nano(n) [1] TRUE > close(s) > n$close() > > s <- ncurl_session("https://postman-echo.com/get", timeout = 1000L) > is_ncurl_session(s) [1] TRUE > if (is_ncurl_session(s)) close(s) > > > > > cleanEx() > nameEx("is_error_value") > ### * is_error_value > > flush(stderr()); flush(stdout()) > > ### Name: is_error_value > ### Title: Error Validators > ### Aliases: is_error_value is_nul_byte > > ### ** Examples > > s <- socket() > r <- recv_aio(s, timeout = 10) > call_aio(r)$data 'errorValue' int 5 | Timed out > close(s) > r$data == 5L [1] TRUE > is_error_value(r$data) [1] TRUE > is_error_value(5L) [1] FALSE > > is_nul_byte(as.raw(0L)) [1] TRUE > is_nul_byte(raw(length = 1L)) [1] TRUE > is_nul_byte(writeBin("", con = raw())) [1] TRUE > is_nul_byte(0L) [1] FALSE > is_nul_byte(NULL) [1] FALSE > is_nul_byte(NA) [1] FALSE > > > > > cleanEx() > nameEx("listen") > ### * listen > > flush(stderr()); flush(stdout()) > > ### Name: listen > ### Title: Listen to an Address from a Socket > ### Aliases: listen > > ### ** Examples > > socket <- socket("req") > listen(socket, url = "inproc://nanolisten", autostart = FALSE) > socket$listener [[1]] < nanoListener > - id: 7 - socket: 14 - state: not started - url: inproc://nanolisten > start(socket$listener[[1]]) > socket$listener [[1]] < nanoListener > - id: 7 - socket: 14 - state: started - url: inproc://nanolisten > close(socket$listener[[1]]) > close(socket) > > nano <- nano("bus") > nano$listen(url = "inproc://nanolisten", autostart = FALSE) > nano$listener [[1]] < nanoListener > - id: 8 - socket: 15 - state: not started - url: inproc://nanolisten > nano$listener_start() > nano$listener [[1]] < nanoListener > - id: 8 - socket: 15 - state: started - url: inproc://nanolisten > close(nano$listener[[1]]) > nano$close() > > > > > cleanEx() > nameEx("mclock") > ### * mclock > > flush(stderr()); flush(stdout()) > > ### Name: mclock > ### Title: Clock Utility > ### Aliases: mclock > > ### ** Examples > > time <- mclock(); msleep(100); mclock() - time [1] 112 > > > > > cleanEx() > nameEx("monitor") > ### * monitor > > flush(stderr()); flush(stdout()) > > ### Name: monitor > ### Title: Monitor a Socket for Pipe Changes > ### Aliases: monitor read_monitor > > ### ** Examples > > cv <- cv() > s <- socket("poly") > s1 <- socket("poly") > > m <- monitor(s, cv) > m < nanoMonitor > - socket: 16 > > listen(s) > dial(s1) > > cv_value(cv) [1] 1 > read_monitor(m) [1] 107030366 > > close(s) > close(s1) > > read_monitor(m) [1] -107030366 > > > > > cleanEx() > nameEx("msleep") > ### * msleep > > flush(stderr()); flush(stdout()) > > ### Name: msleep > ### Title: Sleep Utility > ### Aliases: msleep > > ### ** Examples > > time <- mclock(); msleep(100); mclock() - time [1] 101 > > > > > cleanEx() > nameEx("nano") > ### * nano > > flush(stderr()); flush(stdout()) > > ### Name: nano > ### Title: Create Nano Object > ### Aliases: nano > > ### ** Examples > > nano <- nano("bus", listen = "inproc://nanonext") > nano < nano object > - socket id: 18 - state: opened - protocol: bus - listener: inproc://nanonext > nano$socket < nanoSocket > - id: 18 - state: opened - protocol: bus - listener: inproc://nanonext > nano$listener[[1]] < nanoListener > - id: 10 - socket: 18 - state: started - url: inproc://nanonext > > nano$opt("send-timeout", 1500) > nano$opt("send-timeout") [1] 1500 > > nano$listen(url = "inproc://nanonextgen") > nano$listener [[1]] < nanoListener > - id: 10 - socket: 18 - state: started - url: inproc://nanonext [[2]] < nanoListener > - id: 11 - socket: 18 - state: started - url: inproc://nanonextgen > > nano1 <- nano("bus", dial = "inproc://nanonext") > nano$send("example test", mode = "raw") [1] 0 > nano1$recv("character") [1] "example test" > > nano$close() > nano1$close() > > > > > cleanEx() > nameEx("ncurl") > ### * ncurl > > flush(stderr()); flush(stdout()) > > ### Name: ncurl > ### Title: ncurl > ### Aliases: ncurl > > ### ** Examples > > ncurl( + "https://postman-echo.com/get", + convert = FALSE, + response = c("date", "content-type"), + timeout = 1200L + ) $status ==1811411== Thread 17 nng:task: ==1811411== Invalid read of size 1 ==1811411== at 0x484F1E0: memmove (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/memcheck/../shared/vg_replace_strmem.c:1429) ==1811411== by 0x1143BB19: ssl_write_real (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/mbedtls/library/ssl_msg.c:4868) ==1811411== by 0x1143BB19: mbedtls_ssl_write (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/mbedtls/library/ssl_msg.c:4904) ==1811411== by 0x113FBC9F: conn_send (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/tls/mbedtls/tls.c:282) ==1811411== by 0x113FCCAD: tls_do_send (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/tls/tls_common.c:1018) ==1811411== by 0x113FD60B: tls_tcp_recv_cb (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/tls/tls_common.c:1087) ==1811411== by 0x113D7D1C: nni_taskq_thread (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/taskq.c:47) ==1811411== by 0x113D8F9A: nni_thr_wrap (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/thread.c:92) ==1811411== by 0x1140A67F: nni_plat_thr_main (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/platform/posix/posix_thread.c:237) ==1811411== by 0x56CEC18: start_thread (/usr/src/debug/glibc-2.43-7.fc44.x86_64/nptl/pthread_create.c:454) ==1811411== by 0x57523F3: clone (/usr/src/debug/glibc-2.43-7.fc44.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:100) ==1811411== Address 0x9d24590 is 0 bytes inside a block of size 65 free'd ==1811411== at 0x4843D73: free (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:950) ==1811411== by 0x113F68C3: nni_http_req_reset (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:102) ==1811411== by 0x113F6992: nni_http_req_free (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:128) ==1811411== by 0x113F6992: nni_http_req_free (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:125) ==1811411== by 0x113C0E66: rnng_ncurl (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/ncurl.c:461) ==1811411== by 0x496CDD: R_doDotCall (/data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:790) ==1811411== by 0x4D4C18: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8700) ==1811411== by 0x4E40E1: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==1811411== by 0x4E40E1: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==1811411== by 0x4E44AA: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==1811411== by 0x4E6346: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==1811411== by 0x4E70EF: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==1811411== by 0x4E46B8: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==1811411== by 0x4E46B8: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==1811411== by 0x51CFD3: Rf_ReplIteration (/data/localhost/ripley/R/svn/R-devel/src/main/main.c:264) ==1811411== Block was alloc'd at ==1811411== at 0x4840AE6: malloc (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:447) ==1811411== by 0x113F6757: http_asprintf (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:490) ==1811411== by 0x113F7064: http_req_prepare (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:517) ==1811411== by 0x113F7064: nni_http_req_get_buf (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:564) ==1811411== by 0x113F5CC0: nni_http_write_req (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_conn.c:533) ==1811411== by 0x113F490B: http_txn_cb (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_client.c:262) ==1811411== by 0x113D7D1C: nni_taskq_thread (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/taskq.c:47) ==1811411== by 0x113D8F9A: nni_thr_wrap (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/thread.c:92) ==1811411== by 0x1140A67F: nni_plat_thr_main (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/platform/posix/posix_thread.c:237) ==1811411== by 0x56CEC18: start_thread (/usr/src/debug/glibc-2.43-7.fc44.x86_64/nptl/pthread_create.c:454) ==1811411== by 0x57523F3: clone (/usr/src/debug/glibc-2.43-7.fc44.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:100) ==1811411== ==1811411== Invalid read of size 1 ==1811411== at 0x484F1EE: memmove (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/memcheck/../shared/vg_replace_strmem.c:1429) ==1811411== by 0x1143BB19: ssl_write_real (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/mbedtls/library/ssl_msg.c:4868) ==1811411== by 0x1143BB19: mbedtls_ssl_write (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/mbedtls/library/ssl_msg.c:4904) ==1811411== by 0x113FBC9F: conn_send (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/tls/mbedtls/tls.c:282) ==1811411== by 0x113FCCAD: tls_do_send (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/tls/tls_common.c:1018) ==1811411== by 0x113FD60B: tls_tcp_recv_cb (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/tls/tls_common.c:1087) ==1811411== by 0x113D7D1C: nni_taskq_thread (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/taskq.c:47) ==1811411== by 0x113D8F9A: nni_thr_wrap (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/thread.c:92) ==1811411== by 0x1140A67F: nni_plat_thr_main (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/platform/posix/posix_thread.c:237) ==1811411== by 0x56CEC18: start_thread (/usr/src/debug/glibc-2.43-7.fc44.x86_64/nptl/pthread_create.c:454) ==1811411== by 0x57523F3: clone (/usr/src/debug/glibc-2.43-7.fc44.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:100) ==1811411== Address 0x9d24592 is 2 bytes inside a block of size 65 free'd ==1811411== at 0x4843D73: free (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:950) ==1811411== by 0x113F68C3: nni_http_req_reset (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:102) ==1811411== by 0x113F6992: nni_http_req_free (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:128) ==1811411== by 0x113F6992: nni_http_req_free (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:125) ==1811411== by 0x113C0E66: rnng_ncurl (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/ncurl.c:461) ==1811411== by 0x496CDD: R_doDotCall (/data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:790) ==1811411== by 0x4D4C18: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8700) ==1811411== by 0x4E40E1: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==1811411== by 0x4E40E1: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==1811411== by 0x4E44AA: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==1811411== by 0x4E6346: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==1811411== by 0x4E70EF: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==1811411== by 0x4E46B8: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==1811411== by 0x4E46B8: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==1811411== by 0x51CFD3: Rf_ReplIteration (/data/localhost/ripley/R/svn/R-devel/src/main/main.c:264) ==1811411== Block was alloc'd at ==1811411== at 0x4840AE6: malloc (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:447) ==1811411== by 0x113F6757: http_asprintf (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:490) ==1811411== by 0x113F7064: http_req_prepare (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:517) ==1811411== by 0x113F7064: nni_http_req_get_buf (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_msg.c:564) ==1811411== by 0x113F5CC0: nni_http_write_req (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_conn.c:533) ==1811411== by 0x113F490B: http_txn_cb (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/supplemental/http/http_client.c:262) ==1811411== by 0x113D7D1C: nni_taskq_thread (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/taskq.c:47) ==1811411== by 0x113D8F9A: nni_thr_wrap (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/core/thread.c:92) ==1811411== by 0x1140A67F: nni_plat_thr_main (/data/localhost/ripley/R/packages/tests-vg/nanonext/src/nng/src/platform/posix/posix_thread.c:237) ==1811411== by 0x56CEC18: start_thread (/usr/src/debug/glibc-2.43-7.fc44.x86_64/nptl/pthread_create.c:454) ==1811411== by 0x57523F3: clone (/usr/src/debug/glibc-2.43-7.fc44.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:100) ==1811411== 'errorValue' int 5 | Timed out $headers 'errorValue' int 5 | Timed out $data 'errorValue' int 5 | Timed out > ncurl( + "https://postman-echo.com/get", + response = TRUE, + timeout = 1200L + ) $status [1] 200 $headers $headers$Date [1] "Thu, 30 Jul 2026 17:32:06 GMT" $headers$`Content-Type` [1] "application/json; charset=utf-8" $headers$`Content-Length` [1] "143" $headers$Connection [1] "close" $headers$etag [1] "W/\"8f-7zN8nSad8A9WlFJjKQZB04z5nHE\"" $headers$vary [1] "Accept-Encoding" $headers$`x-envoy-upstream-service-time` [1] "5" $headers$`cf-cache-status` [1] "DYNAMIC" $headers$`Set-Cookie` [1] "sails.sid=s%3AIa33ntmA8wpLjZKe2JmP-jVycrfVk9-m.KIIghHjAcJRmxyTD6gjuc%2BLfjl%2BKJnjAYVIT2ZpDBcs; Path=/; HttpOnly, __cf_bm=wo.UTq_.QRam7EXdrliEyZmq3dHGDYnq_EccdmI5P.Q-1785432726.2080307-1.0.1.1-2gftYNmbACpIKEfFHosIZGzf73_LNuRyRs6obgczkgPW.6sGeGAFNKpkx.pV9q6rYQggF2bVEXKkAkoI6IQ4KTXRXd61TqzTCkDZ3zHDX7cw.FdCHX9XdP2lN2zhga9c; HttpOnly; Secure; Path=/; Domain=postman-echo.com; Expires=Thu, 30 Jul 2026 18:02:06 GMT, _cfuvid=0Bxkrc6CDzPRq_r6ftVIXnn_..cnq0gd09FqfE7NY3k-1785432726.2080307-1.0.1.1-1EUtyKuQWOsKF6h_hC3Ld6TlkFUydsK9fcvoX0H4VFA; HttpOnly; SameSite=None; Secure; Path=/; Domain=postman-echo.com" $headers$Server [1] "cloudflare" $headers$`CF-RAY` [1] "a23619cacfcc50f1-LHR" $data [1] "{\"args\":{},\"headers\":{\"host\":\"postman-echo.com\",\"accept-encoding\":\"gzip, br\",\"x-forwarded-proto\":\"https\"},\"url\":\"https://postman-echo.com/get\"}" > ncurl( + "https://postman-echo.com/put", + method = "PUT", + headers = c(Authorization = "Bearer APIKEY"), + data = "hello world", + timeout = 1500L + ) $status [1] 200 $headers NULL $data [1] "{\"args\":{},\"data\":\"hello world\",\"files\":{},\"form\":{},\"headers\":{\"host\":\"postman-echo.com\",\"content-length\":\"11\",\"authorization\":\"Bearer APIKEY\",\"accept-encoding\":\"gzip, br\",\"x-forwarded-proto\":\"https\",\"content-type\":\"application/json\"},\"json\":null,\"url\":\"https://postman-echo.com/put\"}" > ncurl( + "https://postman-echo.com/post", + method = "POST", + headers = c(`Content-Type` = "application/json"), + data = '{"key":"value"}', + timeout = 1500L + ) $status [1] 200 $headers NULL $data [1] "{\"args\":{},\"data\":{\"key\":\"value\"},\"files\":{},\"form\":{},\"headers\":{\"host\":\"postman-echo.com\",\"content-length\":\"15\",\"content-type\":\"application/json\",\"accept-encoding\":\"gzip, br\",\"x-forwarded-proto\":\"https\"},\"json\":{\"key\":\"value\"},\"url\":\"https://postman-echo.com/post\"}" > > > > > cleanEx() > nameEx("ncurl_aio") > ### * ncurl_aio > > flush(stderr()); flush(stdout()) > > ### Name: ncurl_aio > ### Title: ncurl Async > ### Aliases: ncurl_aio > > ### ** Examples > > nc <- ncurl_aio( + "https://postman-echo.com/get", + response = c("date", "server"), + timeout = 2000L + ) > call_aio(nc) > nc$status [1] 200 > nc$headers $date [1] "Thu, 30 Jul 2026 17:32:08 GMT" $server [1] "cloudflare" > nc$data [1] "{\"args\":{},\"headers\":{\"host\":\"postman-echo.com\",\"accept-encoding\":\"gzip, br\",\"x-forwarded-proto\":\"https\"},\"url\":\"https://postman-echo.com/get\"}" > > ## Don't show: > if (interactive() && requireNamespace("promises", quietly = TRUE)) withAutoprint({ # examplesIf + ## End(Don't show) + library(promises) + p <- as.promise(nc) + print(p) + + p2 <- ncurl_aio("https://postman-echo.com/get") %>% + then(function(x) cat(x$data)) + is.promise(p2) + ## Don't show: + }) # examplesIf > ## End(Don't show) > > > > cleanEx() > nameEx("ncurl_session") > ### * ncurl_session > > flush(stderr()); flush(stdout()) > > ### Name: ncurl_session > ### Title: ncurl Session > ### Aliases: ncurl_session transact > > ### ** Examples > > s <- ncurl_session( + "https://postman-echo.com/get", + response = "date", + timeout = 2000L + ) > s < ncurlSession > - transact() to return data > if (is_ncurl_session(s)) transact(s) $status [1] 200 $headers $headers$date [1] "Thu, 30 Jul 2026 17:32:09 GMT" $data [1] "{\"args\":{},\"headers\":{\"host\":\"postman-echo.com\",\"x-forwarded-proto\":\"https\",\"accept-encoding\":\"gzip, br\"},\"url\":\"https://postman-echo.com/get\"}" > if (is_ncurl_session(s)) close(s) > > > > > cleanEx() > nameEx("nng_error") > ### * nng_error > > flush(stderr()); flush(stdout()) > > ### Name: nng_error > ### Title: Translate Error Codes > ### Aliases: nng_error > > ### ** Examples > > nng_error(1L) [1] "1 | Interrupted" > > > > > cleanEx() > nameEx("nng_version") > ### * nng_version > > flush(stderr()); flush(stdout()) > > ### Name: nng_version > ### Title: NNG Library Version > ### Aliases: nng_version > > ### ** Examples > > nng_version() [1] "1.12.0" "Mbed TLS 3.6.5" > > > > > cleanEx() > nameEx("opt") > ### * opt > > flush(stderr()); flush(stdout()) > > ### Name: opt > ### Title: Get and Set Options for a Socket, Context, Stream, Listener or > ### Dialer > ### Aliases: opt opt<- > > ### ** Examples > > s <- socket("pair") > opt(s, "send-buffer") [1] 0 > close(s) > > s <- socket("req") > ctx <- context(s) > opt(ctx, "send-timeout") [1] -1 > close(ctx) > close(s) > > s <- socket("pair", dial = "inproc://nanonext", autostart = FALSE) > opt(s$dialer[[1]], "reconnect-time-min") [1] 1000 > close(s) > > s <- socket("pair", listen = "inproc://nanonext", autostart = FALSE) > opt(s$listener[[1]], "recv-size-max") [1] 0 > close(s) > > s <- socket("pair") > opt(s, "recv-timeout") <- 2000 > close(s) > > s <- socket("req") > ctx <- context(s) > opt(ctx, "send-timeout") <- 2000 > close(ctx) > close(s) > > s <- socket("pair", dial = "inproc://nanonext", autostart = FALSE) > opt(s$dialer[[1]], "reconnect-time-min") <- 2000 > start(s$dialer[[1]]) > close(s) > > s <- socket("pair", listen = "inproc://nanonext", autostart = FALSE) > opt(s$listener[[1]], "recv-size-max") <- 1024 > start(s$listener[[1]]) > close(s) > > > > > cleanEx() > nameEx("parse_url") > ### * parse_url > > flush(stderr()); flush(stdout()) > > ### Name: parse_url > ### Title: Parse URL > ### Aliases: parse_url > > ### ** Examples > > parse_url("https://user:password@w3.org:8080/type/path?q=info#intro") scheme userinfo hostname port path "https" "user:password" "w3.org" "8080" "/type/path" query fragment "q=info" "intro" > parse_url("tcp://192.168.0.2:5555") scheme userinfo hostname port path "tcp" "" "192.168.0.2" "5555" "" query fragment "" "" > > > > > cleanEx() > nameEx("pipe_notify") > ### * pipe_notify > > flush(stderr()); flush(stdout()) > > ### Name: pipe_notify > ### Title: Pipe Notify > ### Aliases: pipe_notify > > ### ** Examples > > s <- socket(listen = "inproc://nanopipe") > cv <- cv() > > pipe_notify(s, cv, add = TRUE, remove = TRUE, flag = TRUE) > cv_value(cv) [1] 0 > > s1 <- socket(dial = "inproc://nanopipe") > cv_value(cv) [1] 0 > reap(s1) [1] 0 > cv_value(cv) [1] 2 > > pipe_notify(s, NULL, add = TRUE, remove = TRUE) > s1 <- socket(dial = "inproc://nanopipe") > cv_value(cv) [1] 2 > reap(s1) [1] 0 > > (wait(cv)) [1] FALSE > > close(s) > > > > > cleanEx() > nameEx("random") > ### * random > > flush(stderr()); flush(stdout()) > > ### Name: random > ### Title: Random Data Generation > ### Aliases: random > > ### ** Examples > > random() [1] "14" > random(8L) [1] "16905d8e4e2039c6" > random(n = 8L, convert = FALSE) [1] 49 1d 70 91 ef 13 5a 2c > > > > > cleanEx() > nameEx("reap") > ### * reap > > flush(stderr()); flush(stdout()) > > ### Name: reap > ### Title: Reap > ### Aliases: reap > > ### ** Examples > > s <- socket("req") > listen(s) > dial(s) > ctx <- .context(s) > > reap(ctx) [1] 0 > reap(s[["dialer"]][[1]]) [1] 0 > reap(s[["listener"]][[1]]) [1] 0 > reap(s) [1] 0 > reap(s) 'errorValue' int 7 | Object closed > > > > > cleanEx() > nameEx("recv") > ### * recv > > flush(stderr()); flush(stdout()) > > ### Name: recv > ### Title: Receive > ### Aliases: recv > > ### ** Examples > > s1 <- socket("pair", listen = "inproc://nanonext") > s2 <- socket("pair", dial = "inproc://nanonext") > > send(s1, data.frame(a = 1, b = 2)) 'errorValue' int 8 | Try again > res <- recv(s2) > res 'errorValue' int 8 | Try again > send(s1, data.frame(a = 1, b = 2)) [1] 0 > recv(s2) 'errorValue' int 8 | Try again > > send(s1, c(1.1, 2.2, 3.3), mode = "raw") [1] 0 > res <- recv(s2, mode = "double", block = 100) Warning: received data could not be converted to double > res [1] 42 0a 03 00 00 00 00 07 04 00 00 05 03 00 05 00 00 00 55 54 46 2d 38 13 03 [26] 00 00 02 00 00 00 0e 00 00 00 01 00 00 00 00 00 00 00 00 00 f0 3f 0e 00 00 [51] 00 01 00 00 00 00 00 00 00 00 00 00 40 02 04 00 00 01 00 00 00 09 00 04 00 [76] 05 00 00 00 6e 61 6d 65 73 10 00 00 00 02 00 00 00 09 00 04 00 01 00 00 00 [101] 61 09 00 04 00 01 00 00 00 62 02 04 00 00 01 00 00 00 09 00 04 00 05 00 00 [126] 00 63 6c 61 73 73 10 00 00 00 01 00 00 00 09 00 04 00 0a 00 00 00 64 61 74 [151] 61 2e 66 72 61 6d 65 02 04 00 00 01 00 00 00 09 00 04 00 09 00 00 00 72 6f [176] 77 2e 6e 61 6d 65 73 0d 00 00 00 02 00 00 00 00 00 00 80 ff ff ff ff fe 00 [201] 00 00 > send(s1, "example message", mode = "raw") [1] 0 > recv(s2, mode = "character") [1] "\x9a\x99\x99\x99\x99\x99\xf1?\x9a\x99\x99\x99\x99\x99\001@ffffff\n@" > > close(s1) > close(s2) > > req <- socket("req", listen = "inproc://nanonext") > rep <- socket("rep", dial = "inproc://nanonext") > > ctxq <- context(req) > ctxp <- context(rep) > send(ctxq, data.frame(a = 1, b = 2), block = 100) [1] 0 > recv(ctxp, block = 100) a b 1 1 2 > > send(ctxq, c(1.1, 2.2, 3.3), mode = "raw", block = 100) [1] 0 > recv(ctxp, mode = "double", block = 100) [1] 1.1 2.2 3.3 > > close(req) > close(rep) > > > > > cleanEx() > nameEx("recv_aio") > ### * recv_aio > > flush(stderr()); flush(stdout()) > > ### Name: recv_aio > ### Title: Receive Async > ### Aliases: recv_aio > > ### ** Examples > > s1 <- socket("pair", listen = "inproc://nanonext") > s2 <- socket("pair", dial = "inproc://nanonext") > > res <- send_aio(s1, data.frame(a = 1, b = 2), timeout = 100) > msg <- recv_aio(s2, timeout = 100) > msg < recvAio | $data > > msg$data 'unresolved' logi NA > > res <- send_aio(s1, c(1.1, 2.2, 3.3), mode = "raw", timeout = 100) > msg <- recv_aio(s2, mode = "double", timeout = 100) > msg < recvAio | $data > > msg$data [1] 1.1 2.2 3.3 > > res <- send_aio(s1, "example message", mode = "raw", timeout = 100) > msg <- recv_aio(s2, mode = "character", timeout = 100) > call_aio(msg) > msg$data [1] "example message" > > close(s1) > close(s2) > > # Signalling a condition variable > > s1 <- socket("pair", listen = "inproc://cv-example") > cv <- cv() > msg <- recv_aio(s1, timeout = 100, cv = cv) > until(cv, 10L) > msg$data 'unresolved' logi NA > close(s1) > > # in another process in parallel > s2 <- socket("pair", dial = "inproc://cv-example") > res <- send_aio(s2, c(1.1, 2.2, 3.3), mode = "raw", timeout = 100) > close(s2) > > > > > cleanEx() > nameEx("reply") > ### * reply > > flush(stderr()); flush(stdout()) > > ### Name: reply > ### Title: Reply over Context (RPC Server for Req/Rep Protocol) > ### Aliases: reply > > ### ** Examples > > req <- socket("req", listen = "inproc://req-example") > rep <- socket("rep", dial = "inproc://req-example") > > ctxq <- context(req) > ctxp <- context(rep) > > send(ctxq, 2022, block = 100) [1] 0 > reply(ctxp, execute = function(x) x + 1, send_mode = "raw", timeout = 100) [1] 0 > recv(ctxq, mode = "double", block = 100) [1] 2023 > > send(ctxq, 100, mode = "raw", block = 100) [1] 0 > reply(ctxp, recv_mode = "double", execute = log, base = 10, timeout = 100) [1] 0 > recv(ctxq, block = 100) [1] 2 > > close(req) > close(rep) > > > > > cleanEx() > nameEx("request") > ### * request > > flush(stderr()); flush(stdout()) > > ### Name: request > ### Title: Request over Context (RPC Client for Req/Rep Protocol) > ### Aliases: request > > ### ** Examples > > ## Not run: > ##D > ##D # works if req and rep are running in parallel in different processes > ##D > ##D req <- socket("req", listen = "tcp://127.0.0.1:6546") > ##D rep <- socket("rep", dial = "tcp://127.0.0.1:6546") > ##D > ##D reply(.context(rep), execute = function(x) x + 1, timeout = 50) > ##D aio <- request(.context(req), data = 2022) > ##D aio$data > ##D > ##D close(req) > ##D close(rep) > ##D > ##D # Signalling a condition variable > ##D > ##D req <- socket("req", listen = "tcp://127.0.0.1:6546") > ##D ctxq <- context(req) > ##D cv <- cv() > ##D aio <- request(ctxq, data = 2022, cv = cv) > ##D until(cv, 10L) > ##D close(req) > ##D > ##D # The following should be run in another process > ##D rep <- socket("rep", dial = "tcp://127.0.0.1:6546") > ##D ctxp <- context(rep) > ##D reply(ctxp, execute = function(x) x + 1) > ##D close(rep) > ##D > ## End(Not run) > > > > > cleanEx() > nameEx("send") > ### * send > > flush(stderr()); flush(stdout()) > > ### Name: send > ### Title: Send > ### Aliases: send > > ### ** Examples > > pub <- socket("pub", dial = "inproc://nanonext") > > send(pub, data.frame(a = 1, b = 2)) [1] 0 > send(pub, c(10.1, 20.2, 30.3), mode = "raw", block = 100) [1] 0 > > close(pub) > > req <- socket("req", listen = "inproc://nanonext") > rep <- socket("rep", dial = "inproc://nanonext") > > ctx <- context(req) > send(ctx, data.frame(a = 1, b = 2), block = 100) [1] 0 > > msg <- recv_aio(rep, timeout = 100) > send(ctx, c(1.1, 2.2, 3.3), mode = "raw", block = 100) [1] 0 > > close(req) > close(rep) > > > > > cleanEx() > nameEx("send_aio") > ### * send_aio > > flush(stderr()); flush(stdout()) > > ### Name: send_aio > ### Title: Send Async > ### Aliases: send_aio > > ### ** Examples > > pub <- socket("pub", dial = "inproc://nanonext") > > res <- send_aio(pub, data.frame(a = 1, b = 2), timeout = 100) > res < sendAio | $result > > res$result [1] 0 > > res <- send_aio(pub, "example message", mode = "raw", timeout = 100) > call_aio(res)$result [1] 0 > > close(pub) > > > > > cleanEx() > nameEx("serial_config") > ### * serial_config > > flush(stderr()); flush(stdout()) > > ### Name: serial_config > ### Title: Create Serialization Configuration > ### Aliases: serial_config > > ### ** Examples > > cfg <- serial_config("test_cls", function(x) serialize(x, NULL), unserialize) > cfg [[1]] [1] "test_cls" [[2]] [[2]][[1]] function (x) serialize(x, NULL) [[3]] [[3]][[1]] function (connection, refhook = NULL) { if (typeof(connection) != "raw" && !is.character(connection) && !inherits(connection, "connection")) stop("'connection' must be a connection") .Internal(unserialize(connection, refhook)) } > > cfg <- serial_config( + c("class_one", "class_two"), + list(function(x) serialize(x, NULL), function(x) serialize(x, NULL)), + list(unserialize, unserialize) + ) > cfg [[1]] [1] "class_one" "class_two" [[2]] [[2]][[1]] function (x) serialize(x, NULL) [[2]][[2]] function (x) serialize(x, NULL) [[3]] [[3]][[1]] function (connection, refhook = NULL) { if (typeof(connection) != "raw" && !is.character(connection) && !inherits(connection, "connection")) stop("'connection' must be a connection") .Internal(unserialize(connection, refhook)) } [[3]][[2]] function (connection, refhook = NULL) { if (typeof(connection) != "raw" && !is.character(connection) && !inherits(connection, "connection")) stop("'connection' must be a connection") .Internal(unserialize(connection, refhook)) } > > s <- socket() > opt(s, "serial") <- cfg > > # provide an empty list to remove registered functions > opt(s, "serial") <- list() > > close(s) > > > > > cleanEx() > nameEx("socket") > ### * socket > > flush(stderr()); flush(stdout()) > > ### Name: socket > ### Title: Open Socket > ### Aliases: socket > > ### ** Examples > > s <- socket(protocol = "req", listen = "inproc://nanosocket") > s < nanoSocket > - id: 47 - state: opened - protocol: req - listener: inproc://nanosocket > s1 <- socket(protocol = "rep", dial = "inproc://nanosocket") > s1 < nanoSocket > - id: 48 - state: opened - protocol: rep - dialer: inproc://nanosocket > > send(s, "hello world!") [1] 0 > recv(s1) [1] "hello world!" > > close(s1) > close(s) > > > > > cleanEx() > nameEx("stat") > ### * stat > > flush(stderr()); flush(stdout()) > > ### Name: stat > ### Title: Get Statistic for a Socket, Listener or Dialer > ### Aliases: stat > > ### ** Examples > > s <- socket("bus", listen = "inproc://stats") > stat(s, "pipes") [1] 0 > > s1 <- socket("bus", dial = "inproc://stats") > stat(s, "pipes") [1] 1 > > close(s1) > stat(s, "pipes") [1] 0 > > close(s) > > > > > cleanEx() > nameEx("status_code") > ### * status_code > > flush(stderr()); flush(stdout()) > > ### Name: status_code > ### Title: Translate HTTP Status Codes > ### Aliases: status_code > > ### ** Examples > > status_code(200) [1] "200 | OK" > status_code(404) [1] "404 | Not Found" > > > > > cleanEx() > nameEx("stream") > ### * stream > > flush(stderr()); flush(stdout()) > > ### Name: stream > ### Title: Open Stream > ### Aliases: stream > > ### ** Examples > > # Will succeed only if there is an open connection at the address: > s <- tryCatch(stream(dial = "tcp://127.0.0.1:5555"), error = identity) > s > ## Don't show: > if (interactive()) withAutoprint({ # examplesIf + ## End(Don't show) + # Run in interactive sessions only as connection is not always available: + s <- tryCatch( + stream(dial = "wss://echo.websocket.events/", textframes = TRUE), + error = identity + ) + s + if (is_nano(s)) recv(s) + if (is_nano(s)) send(s, "hello") + if (is_nano(s)) recv(s) + if (is_nano(s)) close(s) + ## Don't show: + }) # examplesIf > ## End(Don't show) > > > > cleanEx() > nameEx("subscribe") > ### * subscribe > > flush(stderr()); flush(stdout()) > > ### Name: subscribe > ### Title: Subscribe / Unsubscribe Topic > ### Aliases: subscribe unsubscribe > > ### ** Examples > > pub <- socket("pub", listen = "inproc://nanonext") > sub <- socket("sub", dial = "inproc://nanonext") > > subscribe(sub, "examples") > > send(pub, c("examples", "this is an example"), mode = "raw") [1] 0 > recv(sub, "character") [1] "examples" "this is an example" > send(pub, "examples will also be received", mode = "raw") [1] 0 > recv(sub, "character") [1] "examples will also be received" > send(pub, c("other", "this other topic will not be received"), mode = "raw") [1] 0 > recv(sub, "character") 'errorValue' int 8 | Try again > unsubscribe(sub, "examples") > send(pub, c("examples", "this example is no longer received"), mode = "raw") [1] 0 > recv(sub, "character") 'errorValue' int 8 | Try again > > subscribe(sub, 2) > send(pub, c(2, 10, 10, 20), mode = "raw") [1] 0 > recv(sub, "double") [1] 2 10 10 20 > unsubscribe(sub, 2) > send(pub, c(2, 10, 10, 20), mode = "raw") [1] 0 > recv(sub, "double") 'errorValue' int 8 | Try again > > close(pub) > close(sub) > > > > > cleanEx() > nameEx("survey_time") > ### * survey_time > > flush(stderr()); flush(stdout()) > > ### Name: survey_time > ### Title: Set Survey Time > ### Aliases: survey_time > > ### ** Examples > > sur <- socket("surveyor", listen = "inproc://nanonext") > res <- socket("respondent", dial = "inproc://nanonext") > > survey_time(sur, 1000) > > send(sur, "reply to this survey") [1] 0 > aio <- recv_aio(sur) > > recv(res) [1] "reply to this survey" > s <- send_aio(res, "replied") > > call_aio(aio)$data [1] "replied" > > close(sur) > close(res) > > > > > cleanEx() > nameEx("tls_config") > ### * tls_config > > flush(stderr()); flush(stdout()) > > ### Name: tls_config > ### Title: Create TLS Configuration > ### Aliases: tls_config > > ### ** Examples > > tls <- tls_config() > tls < TLS client config | auth mode: none > > ncurl("https://postman-echo.com/get", timeout = 1000L, tls = tls) $status [1] 200 $headers NULL $data [1] "{\"args\":{},\"headers\":{\"host\":\"postman-echo.com\",\"accept-encoding\":\"gzip, br\",\"x-forwarded-proto\":\"https\"},\"url\":\"https://postman-echo.com/get\"}" > > # client TLS configuration for public internet HTTPS on Linux > # tls <- tls_config(client = "/etc/ssl/certs/ca-certificates.crt") > > > > > cleanEx() > nameEx("unresolved") > ### * unresolved > > flush(stderr()); flush(stdout()) > > ### Name: unresolved > ### Title: Query if an Aio is Unresolved > ### Aliases: unresolved > > ### ** Examples > > s1 <- socket("pair", listen = "inproc://nanonext") > aio <- send_aio(s1, "test", timeout = 100) > > while (unresolved(aio)) { + # do stuff before checking resolution again + cat("unresolved\n") + msleep(100) + } > > unresolved(aio) [1] FALSE > > close(s1) > > > > > cleanEx() > nameEx("write_cert") > ### * write_cert > > flush(stderr()); flush(stdout()) > > ### Name: write_cert > ### Title: Generate Self-Signed Certificate and Key > ### Aliases: write_cert > > ### ** Examples > > ## Don't show: > if (interactive()) withAutoprint({ # examplesIf + ## End(Don't show) + cert <- write_cert(cn = "127.0.0.1") + ser <- tls_config(server = cert$server) + cli <- tls_config(client = cert$client) + + s <- socket(listen = "tls+tcp://127.0.0.1:5555", tls = ser) + s1 <- socket(dial = "tls+tcp://127.0.0.1:5555", tls = cli) + + # secure TLS connection established + + close(s1) + close(s) + + cert + ## Don't show: + }) # examplesIf > ## End(Don't show) > > > > cleanEx() > nameEx("write_stdout") > ### * write_stdout > > flush(stderr()); flush(stdout()) > > ### Name: write_stdout > ### Title: Write to Stdout > ### Aliases: write_stdout > > ### ** Examples > > write_stdout("") > > > > > cleanEx() > nameEx("zzz") > ### * zzz > > flush(stderr()); flush(stdout()) > > ### Name: zzz > ### Title: Internal Package Function > ### Aliases: zzz > ### Keywords: internal > > ### ** Examples > > if (Sys.info()[["sysname"]] == "Linux") { + rm(list = ls()) + invisible(gc()) + .Call(nanonext:::rnng_fini_priors) + Sys.sleep(1L) + .Call(nanonext:::rnng_fini) + } NULL > > > > > ### *