├── .clang-format ├── .codecov.yml ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── pull_request_template.md └── workflows │ ├── codeql-analysis.yml │ ├── coverage.yml │ ├── darwin.yml │ ├── linux.yml │ ├── sanitizer.yml │ └── windows.yml ├── .gitignore ├── .gitmodules ├── .grcov.yml ├── CMakeLists.txt ├── CODE_OF_CONDUCT.adoc ├── LICENSE.txt ├── README.md ├── RELEASE_NOTES.adoc ├── cmake ├── CheckSanitizer.cmake ├── FindMbedTLS.cmake ├── FindwolfSSL.cmake ├── NNGHelpers.cmake ├── NNGOptions.cmake └── nng-config.cmake.in ├── demo ├── async │ ├── CMakeLists.txt │ ├── README.adoc │ ├── client.c │ ├── run.sh │ └── server.c ├── http_client │ ├── CMakeLists.txt │ ├── README.adoc │ └── http_client.c ├── mqtt │ ├── CMakeLists.txt │ └── mqtt_client.c ├── mqtt_async │ ├── CMakeLists.txt │ └── mqtt_async.c ├── mqttv5 │ ├── CMakeLists.txt │ └── mqttv5_client.c ├── mqttv5_scram │ ├── CMakeLists.txt │ └── mqttv5_scram.c ├── multiurls_switch │ ├── CMakeLists.txt │ └── multiurls_switch.c ├── pubsub_forwarder │ ├── CMakeLists.txt │ ├── README.adoc │ └── pubsub_forwarder.c ├── quic_mqtt │ ├── CMakeLists.txt │ └── quic_client.c ├── quic_mqttv5 │ ├── CMakeLists.txt │ └── quic_client_v5.c ├── raw │ ├── CMakeLists.txt │ ├── README.adoc │ └── raw.c ├── reqrep │ ├── CMakeLists.txt │ ├── README.adoc │ └── reqrep.c ├── rest │ ├── CMakeLists.txt │ ├── README.adoc │ └── server.c └── stream │ ├── CMakeLists.txt │ ├── platform │ ├── posix │ │ └── server.c │ └── windows │ │ └── server.c │ └── stream.c ├── docs ├── BUILD_ANDROID.adoc ├── BUILD_CROSSCOMPILE.adoc ├── BUILD_IOS.adoc ├── BUILD_TLS.md ├── BUILD_ZEROTIER.adoc ├── CONTRIBUTING.adoc ├── LICENSE.adoc ├── RATIONALE.adoc ├── README.txt └── man │ ├── CMakeLists.txt │ ├── libnng.3.adoc │ ├── man1.desc │ ├── man1.sect │ ├── man3.desc │ ├── man3.sect │ ├── man3compat.desc │ ├── man3compat.sect │ ├── man3http.desc │ ├── man3http.sect │ ├── man3str.desc │ ├── man3str.sect │ ├── man3supp.desc │ ├── man3supp.sect │ ├── man3tls.desc │ ├── man3tls.sect │ ├── man5.desc │ ├── man5.sect │ ├── man7.desc │ ├── man7.sect │ ├── nn_allocmsg.3compat.adoc │ ├── nn_bind.3compat.adoc │ ├── nn_close.3compat.adoc │ ├── nn_cmsg.3compat.adoc │ ├── nn_connect.3compat.adoc │ ├── nn_device.3compat.adoc │ ├── nn_errno.3compat.adoc │ ├── nn_freemsg.3compat.adoc │ ├── nn_get_statistic.3compat.adoc │ ├── nn_getsockopt.3compat.adoc │ ├── nn_poll.3compat.adoc │ ├── nn_reallocmsg.3compat.adoc │ ├── nn_recv.3compat.adoc │ ├── nn_recvmsg.3compat.adoc │ ├── nn_send.3compat.adoc │ ├── nn_sendmsg.3compat.adoc │ ├── nn_setsockopt.3compat.adoc │ ├── nn_shutdown.3compat.adoc │ ├── nn_socket.3compat.adoc │ ├── nn_strerror.3compat.adoc │ ├── nn_term.3compat.adoc │ ├── nng.7.adoc │ ├── nng_aio.5.adoc │ ├── nng_aio_abort.3.adoc │ ├── nng_aio_alloc.3.adoc │ ├── nng_aio_begin.3.adoc │ ├── nng_aio_busy.3.adoc │ ├── nng_aio_cancel.3.adoc │ ├── nng_aio_count.3.adoc │ ├── nng_aio_defer.3.adoc │ ├── nng_aio_finish.3.adoc │ ├── nng_aio_free.3.adoc │ ├── nng_aio_get_input.3.adoc │ ├── nng_aio_get_msg.3.adoc │ ├── nng_aio_get_output.3.adoc │ ├── nng_aio_result.3.adoc │ ├── nng_aio_set_input.3.adoc │ ├── nng_aio_set_iov.3.adoc │ ├── nng_aio_set_msg.3.adoc │ ├── nng_aio_set_output.3.adoc │ ├── nng_aio_set_timeout.3.adoc │ ├── nng_aio_stop.3.adoc │ ├── nng_aio_wait.3.adoc │ ├── nng_alloc.3.adoc │ ├── nng_bus.7.adoc │ ├── nng_bus_open.3.adoc │ ├── nng_clock.3supp.adoc │ ├── nng_close.3.adoc │ ├── nng_compat.3compat.adoc │ ├── nng_ctx.5.adoc │ ├── nng_ctx_close.3.adoc │ ├── nng_ctx_get.3.adoc │ ├── nng_ctx_getopt.3.adoc │ ├── nng_ctx_id.3.adoc │ ├── nng_ctx_open.3.adoc │ ├── nng_ctx_recv.3.adoc │ ├── nng_ctx_recvmsg.3.adoc │ ├── nng_ctx_send.3.adoc │ ├── nng_ctx_sendmsg.3.adoc │ ├── nng_ctx_set.3.adoc │ ├── nng_ctx_setopt.3.adoc │ ├── nng_cv_alloc.3supp.adoc │ ├── nng_cv_free.3supp.adoc │ ├── nng_cv_until.3supp.adoc │ ├── nng_cv_wait.3supp.adoc │ ├── nng_cv_wake.3supp.adoc │ ├── nng_cv_wake1.3supp.adoc │ ├── nng_device.3.adoc │ ├── nng_dial.3.adoc │ ├── nng_dialer.5.adoc │ ├── nng_dialer_close.3.adoc │ ├── nng_dialer_create.3.adoc │ ├── nng_dialer_get.3.adoc │ ├── nng_dialer_getopt.3.adoc │ ├── nng_dialer_id.3.adoc │ ├── nng_dialer_set.3.adoc │ ├── nng_dialer_setopt.3.adoc │ ├── nng_dialer_start.3.adoc │ ├── nng_duration.5.adoc │ ├── nng_free.3.adoc │ ├── nng_getopt.3.adoc │ ├── nng_http_client_alloc.3http.adoc │ ├── nng_http_client_connect.3http.adoc │ ├── nng_http_client_free.3http.adoc │ ├── nng_http_client_get_tls.3http.adoc │ ├── nng_http_client_set_tls.3http.adoc │ ├── nng_http_client_transact.3http.adoc │ ├── nng_http_conn_close.3http.adoc │ ├── nng_http_conn_read.3http.adoc │ ├── nng_http_conn_read_all.3http.adoc │ ├── nng_http_conn_read_req.3http.adoc │ ├── nng_http_conn_read_res.3http.adoc │ ├── nng_http_conn_transact.3http.adoc │ ├── nng_http_conn_write.3http.adoc │ ├── nng_http_conn_write_all.3http.adoc │ ├── nng_http_conn_write_req.3http.adoc │ ├── nng_http_conn_write_res.3http.adoc │ ├── nng_http_handler_alloc.3http.adoc │ ├── nng_http_handler_collect_body.3http.adoc │ ├── nng_http_handler_free.3http.adoc │ ├── nng_http_handler_get_data.3http.adoc │ ├── nng_http_handler_set_data.3http.adoc │ ├── nng_http_handler_set_host.3http.adoc │ ├── nng_http_handler_set_method.3http.adoc │ ├── nng_http_handler_set_tree.3http.adoc │ ├── nng_http_hijack.3http.adoc │ ├── nng_http_req_add_header.3http.adoc │ ├── nng_http_req_alloc.3http.adoc │ ├── nng_http_req_copy_data.3http.adoc │ ├── nng_http_req_del_header.3http.adoc │ ├── nng_http_req_free.3http.adoc │ ├── nng_http_req_get_data.3http.adoc │ ├── nng_http_req_get_header.3http.adoc │ ├── nng_http_req_get_method.3http.adoc │ ├── nng_http_req_get_uri.3http.adoc │ ├── nng_http_req_get_version.3http.adoc │ ├── nng_http_req_reset.3http.adoc │ ├── nng_http_req_set_data.3http.adoc │ ├── nng_http_req_set_header.3http.adoc │ ├── nng_http_req_set_method.3http.adoc │ ├── nng_http_req_set_uri.3http.adoc │ ├── nng_http_req_set_version.3http.adoc │ ├── nng_http_res_add_header.3http.adoc │ ├── nng_http_res_alloc.3http.adoc │ ├── nng_http_res_alloc_error.3http.adoc │ ├── nng_http_res_copy_data.3http.adoc │ ├── nng_http_res_del_header.3http.adoc │ ├── nng_http_res_free.3http.adoc │ ├── nng_http_res_get_data.3http.adoc │ ├── nng_http_res_get_header.3http.adoc │ ├── nng_http_res_get_reason.3http.adoc │ ├── nng_http_res_get_status.3http.adoc │ ├── nng_http_res_get_version.3http.adoc │ ├── nng_http_res_reset.3http.adoc │ ├── nng_http_res_set_data.3http.adoc │ ├── nng_http_res_set_header.3http.adoc │ ├── nng_http_res_set_reason.3http.adoc │ ├── nng_http_res_set_status.3http.adoc │ ├── nng_http_res_set_version.3http.adoc │ ├── nng_http_server_add_handler.3http.adoc │ ├── nng_http_server_del_handler.3http.adoc │ ├── nng_http_server_get_addr.3http.adoc │ ├── nng_http_server_get_tls.3http.adoc │ ├── nng_http_server_hold.3http.adoc │ ├── nng_http_server_release.3http.adoc │ ├── nng_http_server_res_error.3http.adoc │ ├── nng_http_server_set_error_file.3http.adoc │ ├── nng_http_server_set_error_page.3http.adoc │ ├── nng_http_server_set_tls.3http.adoc │ ├── nng_http_server_start.3http.adoc │ ├── nng_http_server_stop.3http.adoc │ ├── nng_id_map.3supp.adoc │ ├── nng_inproc.7.adoc │ ├── nng_inproc_register.3.adoc │ ├── nng_iov.5.adoc │ ├── nng_ipc.7.adoc │ ├── nng_ipc_options.5.adoc │ ├── nng_ipc_register.3.adoc │ ├── nng_listen.3.adoc │ ├── nng_listener.5.adoc │ ├── nng_listener_close.3.adoc │ ├── nng_listener_create.3.adoc │ ├── nng_listener_get.3.adoc │ ├── nng_listener_getopt.3.adoc │ ├── nng_listener_id.3.adoc │ ├── nng_listener_set.3.adoc │ ├── nng_listener_setopt.3.adoc │ ├── nng_listener_start.3.adoc │ ├── nng_log.3.adoc │ ├── nng_log_get_level.3.adoc │ ├── nng_log_set_facility.3.adoc │ ├── nng_log_set_level.3.adoc │ ├── nng_log_set_logger.3.adoc │ ├── nng_mqtt_client_open.3.adoc │ ├── nng_mqtt_msg_alloc.3.adoc │ ├── nng_mqtt_msg_decode.3.adoc │ ├── nng_mqtt_msg_encode.3.adoc │ ├── nng_mqtt_msg_get_connect.3.adoc │ ├── nng_mqtt_msg_get_packet_type.3.adoc │ ├── nng_mqtt_msg_get_publish.3.adoc │ ├── nng_mqtt_msg_get_subscribe.3.adoc │ ├── nng_mqtt_msg_get_unsubscribe.3.adoc │ ├── nng_mqtt_msg_set_connect.3.adoc │ ├── nng_mqtt_msg_set_packet_type.3.adoc │ ├── nng_mqtt_msg_set_publish.3.adoc │ ├── nng_mqtt_msg_set_subscribe.3.adoc │ ├── nng_mqtt_msg_set_unsubscribe.3.adoc │ ├── nng_mqtt_options.5.adoc │ ├── nng_mqtt_set_cb.3.adoc │ ├── nng_mqtt_set_sqlite.3.adoc │ ├── nng_mqtt_subscribe.3.adoc │ ├── nng_mqtt_subscribe_async.3.adoc │ ├── nng_mqtt_unsubscribe.3.adoc │ ├── nng_mqtt_unsubscribe_async.3.adoc │ ├── nng_mqttv5_client_open.3.adoc │ ├── nng_msg.5.adoc │ ├── nng_msg_alloc.3.adoc │ ├── nng_msg_append.3.adoc │ ├── nng_msg_body.3.adoc │ ├── nng_msg_capacity.3.adoc │ ├── nng_msg_chop.3.adoc │ ├── nng_msg_clear.3.adoc │ ├── nng_msg_dup.3.adoc │ ├── nng_msg_free.3.adoc │ ├── nng_msg_get_pipe.3.adoc │ ├── nng_msg_header.3.adoc │ ├── nng_msg_header_append.3.adoc │ ├── nng_msg_header_chop.3.adoc │ ├── nng_msg_header_clear.3.adoc │ ├── nng_msg_header_insert.3.adoc │ ├── nng_msg_header_len.3.adoc │ ├── nng_msg_header_trim.3.adoc │ ├── nng_msg_insert.3.adoc │ ├── nng_msg_len.3.adoc │ ├── nng_msg_realloc.3.adoc │ ├── nng_msg_reserve.3.adoc │ ├── nng_msg_set_pipe.3.adoc │ ├── nng_msg_trim.3.adoc │ ├── nng_msleep.3supp.adoc │ ├── nng_mtx_alloc.3supp.adoc │ ├── nng_mtx_free.3supp.adoc │ ├── nng_mtx_lock.3supp.adoc │ ├── nng_mtx_unlock.3supp.adoc │ ├── nng_options.5.adoc │ ├── nng_opts_parse.3supp.adoc │ ├── nng_pair.7.adoc │ ├── nng_pair_open.3.adoc │ ├── nng_pipe.5.adoc │ ├── nng_pipe_close.3.adoc │ ├── nng_pipe_dialer.3.adoc │ ├── nng_pipe_get.3.adoc │ ├── nng_pipe_getopt.3.adoc │ ├── nng_pipe_id.3.adoc │ ├── nng_pipe_listener.3.adoc │ ├── nng_pipe_notify.3.adoc │ ├── nng_pipe_socket.3.adoc │ ├── nng_pub.7.adoc │ ├── nng_pub_open.3.adoc │ ├── nng_pull.7.adoc │ ├── nng_pull_open.3.adoc │ ├── nng_push.7.adoc │ ├── nng_push_open.3.adoc │ ├── nng_random.3supp.adoc │ ├── nng_recv.3.adoc │ ├── nng_recv_aio.3.adoc │ ├── nng_recvmsg.3.adoc │ ├── nng_rep.7.adoc │ ├── nng_rep_open.3.adoc │ ├── nng_req.7.adoc │ ├── nng_req_open.3.adoc │ ├── nng_respondent.7.adoc │ ├── nng_respondent_open.3.adoc │ ├── nng_send.3.adoc │ ├── nng_send_aio.3.adoc │ ├── nng_sendmsg.3.adoc │ ├── nng_setopt.3.adoc │ ├── nng_sleep_aio.3.adoc │ ├── nng_sockaddr.5.adoc │ ├── nng_sockaddr_abstract.5.adoc │ ├── nng_sockaddr_in.5.adoc │ ├── nng_sockaddr_in6.5.adoc │ ├── nng_sockaddr_inproc.5.adoc │ ├── nng_sockaddr_ipc.5.adoc │ ├── nng_sockaddr_zt.5.adoc │ ├── nng_socket.5.adoc │ ├── nng_socket.7.adoc │ ├── nng_socket_get.3.adoc │ ├── nng_socket_id.3.adoc │ ├── nng_socket_pair.3supp.adoc │ ├── nng_socket_set.3.adoc │ ├── nng_stat.5.adoc │ ├── nng_stat_bool.3.adoc │ ├── nng_stat_child.3.adoc │ ├── nng_stat_desc.3.adoc │ ├── nng_stat_find.3.adoc │ ├── nng_stat_find_dialer.3.adoc │ ├── nng_stat_find_listener.3.adoc │ ├── nng_stat_find_socket.3.adoc │ ├── nng_stat_name.3.adoc │ ├── nng_stat_next.3.adoc │ ├── nng_stat_string.3.adoc │ ├── nng_stat_timestamp.3.adoc │ ├── nng_stat_type.3.adoc │ ├── nng_stat_unit.3.adoc │ ├── nng_stat_value.3.adoc │ ├── nng_stats_free.3.adoc │ ├── nng_stats_get.3.adoc │ ├── nng_str_sockaddr.3.adoc │ ├── nng_strdup.3.adoc │ ├── nng_stream.5.adoc │ ├── nng_stream_close.3str.adoc │ ├── nng_stream_dialer.5.adoc │ ├── nng_stream_dialer_alloc.3str.adoc │ ├── nng_stream_dialer_close.3str.adoc │ ├── nng_stream_dialer_dial.3str.adoc │ ├── nng_stream_dialer_free.3str.adoc │ ├── nng_stream_dialer_get.3str.adoc │ ├── nng_stream_dialer_set.3str.adoc │ ├── nng_stream_free.3str.adoc │ ├── nng_stream_get.3str.adoc │ ├── nng_stream_listener.5.adoc │ ├── nng_stream_listener_accept.3str.adoc │ ├── nng_stream_listener_alloc.3str.adoc │ ├── nng_stream_listener_close.3str.adoc │ ├── nng_stream_listener_free.3str.adoc │ ├── nng_stream_listener_get.3str.adoc │ ├── nng_stream_listener_listen.3str.adoc │ ├── nng_stream_listener_set.3str.adoc │ ├── nng_stream_recv.3str.adoc │ ├── nng_stream_send.3str.adoc │ ├── nng_stream_set.3str.adoc │ ├── nng_strerror.3.adoc │ ├── nng_strfree.3.adoc │ ├── nng_sub.7.adoc │ ├── nng_sub_open.3.adoc │ ├── nng_surveyor.7.adoc │ ├── nng_surveyor_open.3.adoc │ ├── nng_tcp.7.adoc │ ├── nng_tcp_options.5.adoc │ ├── nng_tcp_register.3.adoc │ ├── nng_thread_create.3supp.adoc │ ├── nng_thread_destroy.3supp.adoc │ ├── nng_thread_set_name.3supp.adoc │ ├── nng_tls.7.adoc │ ├── nng_tls_config.5.adoc │ ├── nng_tls_config_alloc.3tls.adoc │ ├── nng_tls_config_auth_mode.3tls.adoc │ ├── nng_tls_config_ca_chain.3tls.adoc │ ├── nng_tls_config_ca_file.3tls.adoc │ ├── nng_tls_config_cert_key_file.3tls.adoc │ ├── nng_tls_config_free.3tls.adoc │ ├── nng_tls_config_hold.3tls.adoc │ ├── nng_tls_config_own_cert.3tls.adoc │ ├── nng_tls_config_psk.3tls.adoc │ ├── nng_tls_config_server_name.3tls.adoc │ ├── nng_tls_config_version.3tls.adoc │ ├── nng_tls_engine.5.adoc │ ├── nng_tls_engine_description.3tls.adoc │ ├── nng_tls_engine_fips_mode.3tls.adoc │ ├── nng_tls_engine_name.3tls.adoc │ ├── nng_tls_options.5.adoc │ ├── nng_tls_register.3.adoc │ ├── nng_url.5.adoc │ ├── nng_url_clone.3.adoc │ ├── nng_url_free.3.adoc │ ├── nng_url_parse.3.adoc │ ├── nng_version.3.adoc │ ├── nng_ws.7.adoc │ ├── nng_ws_register.3.adoc │ ├── nng_wss_register.3.adoc │ ├── nng_zerotier.7.adoc │ ├── nng_zt_register.3.adoc │ └── nngcat.1.adoc ├── etc ├── README.adoc ├── codecov.sh ├── coverage.sh ├── format-check.sh ├── nng.sublime-project └── pubrefman │ ├── README.adoc │ ├── go.mod │ ├── go.sum │ ├── pubrefman.go │ └── pubrefman2.go ├── include └── nng │ ├── compat │ └── nanomsg │ │ ├── bus.h │ │ ├── inproc.h │ │ ├── ipc.h │ │ ├── nn.h │ │ ├── pair.h │ │ ├── pipeline.h │ │ ├── pubsub.h │ │ ├── reqrep.h │ │ ├── survey.h │ │ ├── tcp.h │ │ └── ws.h │ ├── mqtt │ ├── mqtt_client.h │ ├── mqtt_quic.h │ └── transport │ │ ├── tcp │ │ └── mqtt_tcp.h │ │ └── tls │ │ └── mqtt_tls.h │ ├── nng.h │ ├── protocol │ ├── bus0 │ │ └── bus.h │ ├── pair0 │ │ └── pair.h │ ├── pair1 │ │ └── pair.h │ ├── pipeline0 │ │ ├── pull.h │ │ └── push.h │ ├── pubsub0 │ │ ├── pub.h │ │ └── sub.h │ ├── reqrep0 │ │ ├── rep.h │ │ └── req.h │ └── survey0 │ │ ├── respond.h │ │ └── survey.h │ ├── supplemental │ ├── http │ │ └── http.h │ ├── nanolib │ │ ├── base64.h │ │ ├── file.h │ │ └── log.h │ ├── tls │ │ ├── engine.h │ │ └── tls.h │ └── util │ │ ├── idhash.h │ │ ├── options.h │ │ └── platform.h │ └── transport │ ├── inproc │ └── inproc.h │ ├── ipc │ └── ipc.h │ ├── tcp │ └── tcp.h │ ├── tls │ └── tls.h │ ├── ws │ └── websocket.h │ └── zerotier │ └── zerotier.h ├── src ├── CMakeLists.txt ├── compat │ ├── CMakeLists.txt │ └── nanomsg │ │ ├── CMakeLists.txt │ │ ├── compat_msg_test.c │ │ ├── compat_tcp_test.c │ │ ├── nn.c │ │ └── nuts_compat.h ├── core │ ├── CMakeLists.txt │ ├── aio.c │ ├── aio.h │ ├── aio_test.c │ ├── buf_size_test.c │ ├── defs.h │ ├── device.c │ ├── device.h │ ├── dialer.c │ ├── dialer.h │ ├── errors_test.c │ ├── file.c │ ├── file.h │ ├── id_test.c │ ├── idhash.c │ ├── idhash.h │ ├── init.c │ ├── init.h │ ├── init_test.c │ ├── list.c │ ├── list.h │ ├── list_test.c │ ├── listener.c │ ├── listener.h │ ├── lmq.c │ ├── lmq.h │ ├── log.c │ ├── log_test.c │ ├── message.c │ ├── message.h │ ├── message_test.c │ ├── msgqueue.c │ ├── msgqueue.h │ ├── nng_impl.h │ ├── options.c │ ├── options.h │ ├── panic.c │ ├── panic.h │ ├── pipe.c │ ├── pipe.h │ ├── platform.h │ ├── pollable.c │ ├── pollable.h │ ├── protocol.h │ ├── reap.c │ ├── reap.h │ ├── reconnect_test.c │ ├── sock_test.c │ ├── sockaddr.c │ ├── sockaddr_test.c │ ├── socket.c │ ├── socket.h │ ├── sockfd.c │ ├── sockfd.h │ ├── sockimpl.h │ ├── stats.c │ ├── stats.h │ ├── stats_test.c │ ├── stream.c │ ├── stream.h │ ├── strs.c │ ├── strs.h │ ├── taskq.c │ ├── taskq.h │ ├── tcp.c │ ├── tcp.h │ ├── thread.c │ ├── thread.h │ ├── url.c │ ├── url.h │ └── url_test.c ├── mqtt │ ├── CMakeLists.txt │ ├── protocol │ │ ├── CMakeLists.txt │ │ └── mqtt │ │ │ ├── CMakeLists.txt │ │ │ ├── mqtt_client.c │ │ │ ├── mqtt_quic.c │ │ │ ├── mqttv5_client.c │ │ │ ├── mqttv5_quic.c │ │ │ ├── sqlite_handler.c │ │ │ └── sqlite_handler.h │ ├── transport.c │ ├── transport.h │ └── transport │ │ ├── CMakeLists.txt │ │ ├── tcp │ │ ├── CMakeLists.txt │ │ └── mqtt_tcp.c │ │ └── tls │ │ ├── CMakeLists.txt │ │ └── mqtt_tls.c ├── nng.c ├── nng_legacy.c ├── platform │ ├── CMakeLists.txt │ ├── platform_test.c │ ├── posix │ │ ├── CMakeLists.txt │ │ ├── posix_aio.h │ │ ├── posix_alloc.c │ │ ├── posix_atomic.c │ │ ├── posix_clock.c │ │ ├── posix_config.h │ │ ├── posix_debug.c │ │ ├── posix_file.c │ │ ├── posix_impl.h │ │ ├── posix_ipc.h │ │ ├── posix_ipcconn.c │ │ ├── posix_ipcdial.c │ │ ├── posix_ipclisten.c │ │ ├── posix_ipcwinsec_test.c │ │ ├── posix_peerid.c │ │ ├── posix_peerid.h │ │ ├── posix_pipe.c │ │ ├── posix_pollq.h │ │ ├── posix_pollq_epoll.c │ │ ├── posix_pollq_kqueue.c │ │ ├── posix_pollq_poll.c │ │ ├── posix_pollq_port.c │ │ ├── posix_rand_arc4random.c │ │ ├── posix_rand_getrandom.c │ │ ├── posix_rand_urandom.c │ │ ├── posix_resolv_gai.c │ │ ├── posix_sockaddr.c │ │ ├── posix_socketpair.c │ │ ├── posix_sockfd.c │ │ ├── posix_tcp.h │ │ ├── posix_tcpconn.c │ │ ├── posix_tcpdial.c │ │ ├── posix_tcplisten.c │ │ ├── posix_thread.c │ │ └── posix_udp.c │ ├── resolver_test.c │ ├── udp_test.c │ └── windows │ │ ├── CMakeLists.txt │ │ ├── win_clock.c │ │ ├── win_debug.c │ │ ├── win_file.c │ │ ├── win_impl.h │ │ ├── win_io.c │ │ ├── win_ipc.h │ │ ├── win_ipc_sec_test.c │ │ ├── win_ipcconn.c │ │ ├── win_ipcdial.c │ │ ├── win_ipclisten.c │ │ ├── win_pipe.c │ │ ├── win_rand.c │ │ ├── win_resolv.c │ │ ├── win_sockaddr.c │ │ ├── win_socketpair.c │ │ ├── win_tcp.c │ │ ├── win_tcp.h │ │ ├── win_tcpconn.c │ │ ├── win_tcpdial.c │ │ ├── win_tcplisten.c │ │ ├── win_thread.c │ │ └── win_udp.c ├── sp │ ├── CMakeLists.txt │ ├── protocol.c │ ├── protocol │ │ ├── CMakeLists.txt │ │ ├── bus0 │ │ │ ├── CMakeLists.txt │ │ │ ├── bus.c │ │ │ └── bus_test.c │ │ ├── pair0 │ │ │ ├── CMakeLists.txt │ │ │ ├── pair.c │ │ │ └── pair0_test.c │ │ ├── pair1 │ │ │ ├── CMakeLists.txt │ │ │ ├── pair.c │ │ │ ├── pair1_poly.c │ │ │ ├── pair1_poly_test.c │ │ │ └── pair1_test.c │ │ ├── pipeline0 │ │ │ ├── CMakeLists.txt │ │ │ ├── pull.c │ │ │ ├── pull_test.c │ │ │ ├── push.c │ │ │ └── push_test.c │ │ ├── pubsub0 │ │ │ ├── CMakeLists.txt │ │ │ ├── pub.c │ │ │ ├── pub_test.c │ │ │ ├── sub.c │ │ │ ├── sub_test.c │ │ │ ├── xsub.c │ │ │ └── xsub_test.c │ │ ├── reqrep0 │ │ │ ├── CMakeLists.txt │ │ │ ├── rep.c │ │ │ ├── rep_test.c │ │ │ ├── req.c │ │ │ ├── req_test.c │ │ │ ├── xrep.c │ │ │ ├── xrep_test.c │ │ │ ├── xreq.c │ │ │ └── xreq_test.c │ │ └── survey0 │ │ │ ├── CMakeLists.txt │ │ │ ├── respond.c │ │ │ ├── respond_test.c │ │ │ ├── survey.c │ │ │ ├── survey_test.c │ │ │ ├── xrespond.c │ │ │ ├── xrespond_test.c │ │ │ ├── xsurvey.c │ │ │ └── xsurvey_test.c │ ├── transport.c │ ├── transport.h │ └── transport │ │ ├── CMakeLists.txt │ │ ├── inproc │ │ ├── CMakeLists.txt │ │ └── inproc.c │ │ ├── ipc │ │ ├── CMakeLists.txt │ │ ├── ipc.c │ │ └── ipc_test.c │ │ ├── socket │ │ ├── CMakeLists.txt │ │ ├── sockfd.c │ │ └── sockfd_test.c │ │ ├── tcp │ │ ├── CMakeLists.txt │ │ ├── tcp.c │ │ └── tcp_test.c │ │ ├── tls │ │ ├── CMakeLists.txt │ │ ├── tls.c │ │ └── tls_tran_test.c │ │ ├── ws │ │ ├── CMakeLists.txt │ │ ├── README.adoc │ │ ├── websocket.c │ │ └── ws_test.c │ │ └── zerotier │ │ ├── CMakeLists.txt │ │ ├── zerotier.c │ │ ├── zthash.c │ │ └── zthash.h ├── supplemental │ ├── CMakeLists.txt │ ├── README.adoc │ ├── base64 │ │ ├── CMakeLists.txt │ │ ├── base64.c │ │ ├── base64.h │ │ └── base64_test.c │ ├── http │ │ ├── CMakeLists.txt │ │ ├── http_api.h │ │ ├── http_chunk.c │ │ ├── http_client.c │ │ ├── http_conn.c │ │ ├── http_msg.c │ │ ├── http_public.c │ │ ├── http_schemes.c │ │ └── http_server.c │ ├── mqtt │ │ ├── CMakeLists.txt │ │ ├── mqtt_codec.c │ │ ├── mqtt_msg.c │ │ ├── mqtt_msg.h │ │ ├── mqtt_public.c │ │ ├── mqtt_qos_db.c │ │ ├── mqtt_qos_db.h │ │ ├── mqtt_qos_db_api.c │ │ ├── mqtt_qos_db_api.h │ │ ├── mqtt_qos_db_test.c │ │ └── mqtt_test.c │ ├── nanolib │ │ ├── CMakeLists.txt │ │ ├── base64.c │ │ ├── file.c │ │ └── log.c │ ├── quic │ │ ├── CMakeLists.txt │ │ ├── msquic │ │ │ └── CMakeLists.txt │ │ ├── quic_api.c │ │ └── quic_api.h │ ├── scram │ │ ├── CMakeLists.txt │ │ ├── scram.c │ │ ├── scram.h │ │ └── scram_test.c │ ├── sha1 │ │ ├── CMakeLists.txt │ │ ├── sha1.c │ │ ├── sha1.h │ │ └── sha1_test.c │ ├── sqlite │ │ ├── CMakeLists.txt │ │ ├── sqlite3.c │ │ ├── sqlite3.h │ │ └── sqlite3_test.c │ ├── tls │ │ ├── CMakeLists.txt │ │ ├── mbedtls │ │ │ ├── CMakeLists.txt │ │ │ └── tls.c │ │ ├── tls_api.h │ │ ├── tls_common.c │ │ ├── tls_test.c │ │ └── wolfssl │ │ │ ├── CMakeLists.txt │ │ │ └── wolfssl.c │ ├── util │ │ ├── CMakeLists.txt │ │ ├── idhash.c │ │ ├── idhash_test.c │ │ ├── options.c │ │ └── platform.c │ └── websocket │ │ ├── CMakeLists.txt │ │ ├── stub.c │ │ ├── websocket.c │ │ ├── websocket.h │ │ ├── websocket_test.c │ │ └── wssfile_test.c ├── testing │ ├── CMakeLists.txt │ ├── acutest.h │ ├── certs.c │ ├── marry.c │ ├── nuts.h │ ├── streams.c │ └── util.c └── tools │ ├── CMakeLists.txt │ ├── nngcat │ ├── CMakeLists.txt │ ├── nngcat.c │ ├── nngcat_ambiguous_test.sh │ ├── nngcat_async_test.sh │ ├── nngcat_dup_proto_test.sh │ ├── nngcat_help_test.sh │ ├── nngcat_incompat_test.sh │ ├── nngcat_need_proto_test.sh │ ├── nngcat_pubsub_test.sh │ ├── nngcat_recvmaxsz_test.sh │ ├── nngcat_stdin_pipe_test.sh │ └── nngcat_unlimited_test.sh │ └── perf │ ├── CMakeLists.txt │ ├── perf.c │ └── pubdrop.c └── tests ├── CMakeLists.txt ├── README.adoc ├── compat_block.c ├── compat_bug777.c ├── compat_bus.c ├── compat_cmsg.c ├── compat_device.c ├── compat_iovec.c ├── compat_msg.c ├── compat_options.c ├── compat_pair.c ├── compat_pipeline.c ├── compat_poll.c ├── compat_reqrep.c ├── compat_reqttl.c ├── compat_shutdown.c ├── compat_survey.c ├── compat_surveyttl.c ├── compat_testutil.c ├── compat_testutil.h ├── convey.c ├── convey.h ├── cplusplus_pair.cc ├── device.c ├── files.c ├── httpclient.c ├── httpserver.c ├── inproc.c ├── ipc.c ├── ipcsupp.c ├── multistress.c ├── nonblock.c ├── options.c ├── pipe.c ├── pollfd.c ├── reqctx.c ├── reqstress.c ├── scalability.c ├── stubs.h ├── synch.c ├── tcp.c ├── tcp6.c ├── tcpsupp.c ├── tls.c ├── trantest.h ├── ws.c ├── wss.c └── zt.c /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: WebKit 2 | UseTab: ForIndentation 3 | IndentWidth: 8 4 | ColumnLimit: 79 5 | AlignConsecutiveAssignments: true 6 | AlignConsecutiveDeclarations: true 7 | AlignTrailingComments: true 8 | AlignEscapedNewlines: Left 9 | PointerAlignment: Right 10 | DerivePointerAlignment: false 11 | ForEachMacros: ['NNI_LIST_FOREACH'] 12 | AlwaysBreakAfterReturnType: TopLevelDefinitions 13 | SpaceAfterCStyleCast: true 14 | AllowShortFunctionsOnASingleLine: Inline 15 | BreakBeforeBinaryOperators: None 16 | TabWidth: 8 17 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "tests" 3 | - "src/testing" 4 | - "perf" 5 | - "**/*_test.c" 6 | coverage: 7 | range: 50..95 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Expected behavior** 14 | A clear and concise description of what you expected to happen. 15 | 16 | **Actual Behavior** 17 | Describe what occurred. 18 | 19 | **To Reproduce** 20 | If possible include actual reproduction test code here. 21 | Minimal C test cases are perferred. 22 | 23 | ** Environment Details ** 24 | - NanoSDK/NNG version 25 | - Operating system and version 26 | - Compiler and language used 27 | - Shared or static library 28 | - Remote MQTT Broker info 29 | - Messaging scenario 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | fixes # 2 | 3 | 4 | 5 | Note that the above format should be used in your git commit comments. 6 | You agree that by submitting a PR, you have read and agreed to our 7 | contributing guidelines. 8 | -------------------------------------------------------------------------------- /.github/workflows/darwin.yml: -------------------------------------------------------------------------------- 1 | name: darwin 2 | on: [push, pull_request] 3 | jobs: 4 | build: 5 | name: build 6 | runs-on: [macos-latest] 7 | steps: 8 | - name: Check out code 9 | uses: actions/checkout@v1 10 | 11 | - name: Install Mbed TLS 12 | run: brew install mbedtls 13 | 14 | - name: Install ninja 15 | run: brew install ninja 16 | 17 | - name: Configure 18 | run: mkdir build && cd build && cmake -G Ninja -DNNG_ENABLE_TLS=ON .. 19 | 20 | - name: build 21 | run: cd build && ninja 22 | 23 | - name: Test 24 | run: cd build && ctest --output-on-failure 25 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: linux 2 | on: [push, pull_request] 3 | jobs: 4 | 5 | build: 6 | name: build 7 | runs-on: [ ubuntu-latest ] 8 | steps: 9 | - name: Check out code 10 | uses: actions/checkout@v1 11 | 12 | - name: Install mbedTLS 13 | run: sudo apt-get install libmbedtls-dev 14 | 15 | - name: Install ninja 16 | run: sudo apt-get install ninja-build 17 | 18 | - name: Configure 19 | run: mkdir build && cd build && cmake -G Ninja -D NNG_ENABLE_TLS=ON .. 20 | 21 | - name: Build 22 | run: cd build && ninja 23 | 24 | - name: Test 25 | run: cd build && ctest --output-on-failure -------------------------------------------------------------------------------- /.github/workflows/sanitizer.yml: -------------------------------------------------------------------------------- 1 | name: sanitize 2 | on: [push, pull_request] 3 | jobs: 4 | sanitize: 5 | env: 6 | CC: clang 7 | CXX: clang++ 8 | CTEST_OUTPUT_ON_FAILURE: 1 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | sanitizer: [ address, undefined, thread ] 13 | os: [ ubuntu-latest ] 14 | 15 | steps: 16 | - uses: actions/checkout@v1 17 | 18 | - name: Install mbedTLS 19 | run: sudo apt-get install libmbedtls-dev 20 | 21 | - name: Install ninja 22 | run: sudo apt-get install ninja-build 23 | 24 | - name: Configure 25 | run: | 26 | mkdir build 27 | cd build 28 | cmake -G Ninja -DNNG_SANITIZER=${{ matrix.sanitizer }} -DCMAKE_BUILD_TYPE=Debug -DNNG_ENABLE_TLS=ON -DNNG_TOOLS=OFF .. 29 | - name: Build 30 | run: | 31 | cd build 32 | ninja 33 | - name: Test 34 | run: | 35 | cd build 36 | ninja test 37 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: windows 2 | on: [push, pull_request] 3 | jobs: 4 | build: 5 | name: build 6 | runs-on: [windows-latest] 7 | steps: 8 | - name: Check out code 9 | uses: actions/checkout@v1 10 | 11 | - name: vcpkg build 12 | id: vcpkg 13 | uses: johnwason/vcpkg-action@v6 14 | with: 15 | pkgs: mbedtls 16 | triplet: x64-windows 17 | token: ${{ github.token }} 18 | github-binarycache: true 19 | 20 | - name: Configure 21 | # TLS on Windows is not good because vcpkg is *old* mbedTLS 2.28, and we don't pass some newer tests. 22 | # We should explore testing WolfSSL here instead. 23 | run: cmake ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} -B build 24 | 25 | - name: Build 26 | run: cmake --build build 27 | 28 | - name: Test 29 | run: | 30 | cd build 31 | ctest -C Debug --output-on-failure 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | lxbuild 3 | winbuild 4 | wbuild 5 | .cache 6 | .vs 7 | .vscode/.cmaketools.json 8 | .vscode 9 | .idea 10 | .DS_Store 11 | etc/nng.sublime-workspace 12 | cmake-build-* 13 | docs/**/*.html -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "extern/msquic"] 2 | path = extern/msquic 3 | url = https://github.com/microsoft/msquic.git 4 | -------------------------------------------------------------------------------- /.grcov.yml: -------------------------------------------------------------------------------- 1 | branch: true 2 | ignore-not-existing: true 3 | filter: covered 4 | output-type: lcov 5 | output-file: lcov.info -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright 2021 Staysail Systems, Inc. 4 | Copyright 2018 Capitar IT Group BV 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom 11 | the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /cmake/CheckSanitizer.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Staysail Systems, Inc. 3 | # Copyright 2017 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | macro (CheckSanitizer) 12 | 13 | if (CMAKE_C_COMPILER_ID STREQUAL "GNU") 14 | set(NNG_SAN_LIST none address leak memory thread undefined) 15 | elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") 16 | set(NNG_SAN_LIST none address leak memory thread undefined) 17 | elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang") 18 | set(NNG_SAN_LIST none address thread undefined) 19 | else () 20 | set(NNG_SAN_LIST none) 21 | endif () 22 | set (NNG_SANITIZER none CACHE STRING "Sanitizer to use (clang or gcc).") 23 | set_property(CACHE NNG_SANITIZER PROPERTY STRINGS ${NNG_SAN_LIST}) 24 | mark_as_advanced (NNG_SANITIZER) 25 | 26 | if (NOT NNG_SANITIZER STREQUAL "none") 27 | set (NNG_C_FLAG_SANITIZER "-fsanitize=${NNG_SANITIZER}") 28 | message(STATUS "Enabling sanitizer: ${NNG_C_FLAG_SANITIZER}") 29 | endif() 30 | endmacro () 31 | -------------------------------------------------------------------------------- /cmake/nng-config.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Staysail Systems, Inc. 2 | # 3 | # This software is supplied under the terms of the MIT License, a 4 | # copy of which should be located in the distribution where this 5 | # file was obtained (LICENSE.txt). A copy of the license may also be 6 | # found online at https://opensource.org/licenses/MIT. 7 | 8 | 9 | @PACKAGE_INIT@ 10 | 11 | set(NNG_MAJOR_VERSION "@NNG_MAJOR_VERSION@") 12 | set(NNG_MINOR_VERSION "@NNG_MINOR_VERSION@") 13 | set(NNG_PATCH_VERSION "@NNG_PATCH_VERSION@") 14 | 15 | set_and_check(NNG_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIRS@") 16 | 17 | include("${CMAKE_CURRENT_LIST_DIR}/nng-targets.cmake") 18 | 19 | # Make sure we find packages for our dependencies 20 | foreach(_PKG IN ITEMS @NNG_PKGS@) 21 | find_package(${_PKG} REQUIRED) 22 | endforeach () 23 | 24 | set(NNG_LIBRARY nng::nng) 25 | 26 | check_required_components(@PROJECT_NAME@) 27 | -------------------------------------------------------------------------------- /demo/async/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Capitar IT Group BV 3 | # Copyright 2018 Staysail Systems, Inc. 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | 10 | cmake_minimum_required(VERSION 3.13) 11 | 12 | project(nng-asyncdemo) 13 | 14 | set(PARALLEL 128 CACHE STRING "Parallelism (min 4, max 1000)") 15 | 16 | if (BUILD_DEMO) 17 | else () 18 | # Call this from your own project's makefile. 19 | find_package(nng CONFIG REQUIRED) 20 | endif (BUILD_DEMO) 21 | 22 | find_package(Threads) 23 | 24 | if (DEBUG) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 26 | if (ASAN) 27 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 28 | endif (ASAN) 29 | if (TSAN) 30 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 31 | endif (TSAN) 32 | endif (DEBUG) 33 | 34 | add_executable(server server.c) 35 | target_link_libraries(server nng) 36 | target_compile_definitions(server PRIVATE NNG_ELIDE_DEPRECATED PARALLEL=${PARALLEL}) 37 | 38 | add_executable(client client.c) 39 | target_link_libraries(client nng) 40 | target_compile_definitions(client PRIVATE NNG_ELIDE_DEPRECATED) 41 | -------------------------------------------------------------------------------- /demo/async/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ADDR=ipc:///tmp/async_demo 4 | COUNT=10 5 | 6 | ./server $ADDR & 7 | SERVER_PID=$! 8 | trap "kill $SERVER_PID" 0 9 | typeset -a CLIENT_PID 10 | i=0 11 | sleep 1 12 | while (( i < COUNT )) 13 | do 14 | i=$(( i + 1 )) 15 | rnd=$(( RANDOM % 1000 + 500 )) 16 | echo "Starting client $i: server replies after $rnd msec" 17 | ./client $ADDR $rnd & 18 | eval CLIENT_PID[$i]=$! 19 | done 20 | 21 | i=0 22 | while (( i < COUNT )) 23 | do 24 | i=$(( i + 1 )) 25 | wait ${CLIENT_PID[$i]} 26 | done 27 | kill $SERVER_PID 28 | -------------------------------------------------------------------------------- /demo/http_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Capitar IT Group BV 3 | # Copyright 2018 Staysail Systems, Inc. 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | 10 | cmake_minimum_required(VERSION 3.13) 11 | 12 | project(http_client) 13 | 14 | # Call this from your own project's makefile. 15 | 16 | if (BUILD_DEMO) 17 | else () 18 | # Call this from your own project's makefile. 19 | find_package(nng CONFIG REQUIRED) 20 | endif (BUILD_DEMO) 21 | 22 | find_package(Threads) 23 | 24 | if (DEBUG) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 26 | if (ASAN) 27 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 28 | endif (ASAN) 29 | if (TSAN) 30 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 31 | endif (TSAN) 32 | endif (DEBUG) 33 | 34 | add_executable(http_client http_client.c) 35 | target_link_libraries(http_client nng) 36 | target_compile_definitions(http_client PRIVATE NNG_ELIDE_DEPRECATED) 37 | -------------------------------------------------------------------------------- /demo/mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | 7 | cmake_minimum_required(VERSION 3.13) 8 | 9 | project(mqtt_client) 10 | 11 | if (BUILD_DEMO) 12 | else () 13 | # Call this from your own project's makefile. 14 | find_package(nng CONFIG REQUIRED) 15 | endif (BUILD_DEMO) 16 | 17 | find_package(Threads) 18 | 19 | if (DEBUG) 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 21 | if (ASAN) 22 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 23 | endif (ASAN) 24 | if (TSAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 26 | endif (TSAN) 27 | endif (DEBUG) 28 | 29 | add_executable(mqtt_client mqtt_client.c) 30 | target_link_libraries(mqtt_client nng) 31 | target_link_libraries(mqtt_client ${CMAKE_THREAD_LIBS_INIT}) 32 | 33 | if(NNG_ENABLE_TLS) 34 | find_package(MbedTLS) 35 | target_link_libraries(mqtt_client mbedtls mbedx509 mbedcrypto) 36 | add_definitions(-DNNG_SUPP_TLS) 37 | endif() 38 | 39 | if(NNG_ENABLE_SQLITE) 40 | add_definitions(-DNNG_SUPP_SQLITE) 41 | target_link_libraries(mqtt_client dl) 42 | endif(NNG_ENABLE_SQLITE) 43 | 44 | target_compile_definitions(mqtt_client PRIVATE NNG_ELIDE_DEPRECATED) 45 | -------------------------------------------------------------------------------- /demo/mqtt_async/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | 7 | cmake_minimum_required(VERSION 3.13) 8 | 9 | project(mqtt_async) 10 | 11 | if (BUILD_DEMO) 12 | else () 13 | # Call this from your own project's makefile. 14 | find_package(nng CONFIG REQUIRED) 15 | endif (BUILD_DEMO) 16 | 17 | find_package(Threads) 18 | 19 | if (DEBUG) 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 21 | if (ASAN) 22 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 23 | endif (ASAN) 24 | if (TSAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 26 | endif (TSAN) 27 | endif (DEBUG) 28 | 29 | add_executable(mqtt_async mqtt_async.c) 30 | target_link_libraries(mqtt_async nng) 31 | target_link_libraries(mqtt_async ${CMAKE_THREAD_LIBS_INIT}) 32 | 33 | if(NNG_ENABLE_TLS) 34 | add_definitions(-DNNG_SUPP_TLS) 35 | endif() 36 | 37 | if (NNG_ENABLE_SQLITE) 38 | add_definitions(-DNNG_SUPP_SQLITE) 39 | target_link_libraries(mqtt_async dl) 40 | endif (NNG_ENABLE_SQLITE) 41 | 42 | target_compile_definitions(mqtt_async PRIVATE NNG_ELIDE_DEPRECATED) -------------------------------------------------------------------------------- /demo/mqttv5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | 7 | cmake_minimum_required(VERSION 3.13) 8 | 9 | project(mqttv5_client) 10 | 11 | if (BUILD_DEMO) 12 | else () 13 | # Call this from your own project's makefile. 14 | find_package(nng CONFIG REQUIRED) 15 | endif (BUILD_DEMO) 16 | 17 | find_package(Threads) 18 | 19 | if (DEBUG) 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 21 | if (ASAN) 22 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 23 | endif (ASAN) 24 | if (TSAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 26 | endif (TSAN) 27 | endif (DEBUG) 28 | 29 | add_executable(mqttv5_client mqttv5_client.c) 30 | target_link_libraries(mqttv5_client nng) 31 | target_link_libraries(mqttv5_client ${CMAKE_THREAD_LIBS_INIT}) 32 | 33 | if(NNG_ENABLE_TLS) 34 | find_package(MbedTLS) 35 | target_link_libraries(mqttv5_client mbedtls mbedx509 mbedcrypto) 36 | add_definitions(-DNNG_SUPP_TLS) 37 | endif() 38 | 39 | if (NNG_ENABLE_SQLITE) 40 | add_definitions(-DNNG_SUPP_SQLITE) 41 | target_link_libraries(mqttv5_client dl) 42 | endif (NNG_ENABLE_SQLITE) 43 | 44 | target_compile_definitions(mqttv5_client PRIVATE NNG_ELIDE_DEPRECATED) 45 | -------------------------------------------------------------------------------- /demo/mqttv5_scram/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | 7 | cmake_minimum_required(VERSION 3.13) 8 | 9 | project(mqttv5_scram) 10 | 11 | if (BUILD_DEMO) 12 | else () 13 | # Call this from your own project's makefile. 14 | find_package(nng CONFIG REQUIRED) 15 | endif (BUILD_DEMO) 16 | 17 | find_package(Threads) 18 | 19 | if (DEBUG) 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 21 | if (ASAN) 22 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 23 | endif (ASAN) 24 | if (TSAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 26 | endif (TSAN) 27 | endif (DEBUG) 28 | 29 | add_executable(mqttv5_scram mqttv5_scram.c) 30 | target_link_libraries(mqttv5_scram nng) 31 | target_link_libraries(mqttv5_scram ${CMAKE_THREAD_LIBS_INIT}) 32 | 33 | target_compile_definitions(mqttv5_scram PRIVATE NNG_ELIDE_DEPRECATED) 34 | -------------------------------------------------------------------------------- /demo/multiurls_switch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | 7 | cmake_minimum_required(VERSION 3.13) 8 | 9 | project(multiurls_switch) 10 | 11 | if (BUILD_DEMO) 12 | else () 13 | # Call this from your own project's makefile. 14 | find_package(nng CONFIG REQUIRED) 15 | endif (BUILD_DEMO) 16 | 17 | find_package(Threads) 18 | 19 | if (DEBUG) 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 21 | if (ASAN) 22 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 23 | endif (ASAN) 24 | if (TSAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 26 | endif (TSAN) 27 | endif (DEBUG) 28 | 29 | add_executable(multiurls_switch multiurls_switch.c) 30 | target_link_libraries(multiurls_switch nng) 31 | target_link_libraries(multiurls_switch ${CMAKE_THREAD_LIBS_INIT}) 32 | 33 | target_compile_definitions(multiurls_switch PRIVATE NNG_ELIDE_DEPRECATED) 34 | -------------------------------------------------------------------------------- /demo/pubsub_forwarder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This software is supplied under the terms of the MIT License, a 2 | # copy of which should be located in the distribution where this 3 | # file was obtained (LICENSE.txt). A copy of the license may also be 4 | # found online at https://opensource.org/licenses/MIT. 5 | 6 | cmake_minimum_required(VERSION 3.10) 7 | project(pubsub_forwarder C) 8 | 9 | # Find the nng library 10 | find_package(nng REQUIRED) 11 | 12 | # Add the executable target 13 | add_executable(pubsub_forwarder pubsub_forwarder.c) 14 | 15 | target_compile_options(pubsub_forwarder PRIVATE -Wall -Wextra -Wpedantic -Werror -O2) 16 | 17 | # Link against the nng library 18 | target_link_libraries(pubsub_forwarder PRIVATE nng) 19 | -------------------------------------------------------------------------------- /demo/raw/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Capitar IT Group BV 3 | # Copyright 2018 Staysail Systems, Inc. 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | 10 | cmake_minimum_required(VERSION 3.13) 11 | 12 | project(raw) 13 | 14 | set(PARALLEL 128 CACHE STRING "Parallelism (min 4, max 1000)") 15 | 16 | if (BUILD_DEMO) 17 | else () 18 | # Call this from your own project's makefile. 19 | find_package(nng CONFIG REQUIRED) 20 | endif (BUILD_DEMO) 21 | 22 | find_package(Threads) 23 | 24 | if (DEBUG) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 26 | if (ASAN) 27 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 28 | endif (ASAN) 29 | if (TSAN) 30 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 31 | endif (TSAN) 32 | endif (DEBUG) 33 | 34 | add_executable(raw raw.c) 35 | target_link_libraries(raw nng) 36 | target_compile_definitions(raw PRIVATE NNG_ELIDE_DEPRECATED PARALLEL=${PARALLEL}) 37 | -------------------------------------------------------------------------------- /demo/reqrep/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Capitar IT Group BV 3 | # Copyright 2018 Staysail Systems, Inc. 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | 10 | cmake_minimum_required(VERSION 3.13) 11 | 12 | project(reqrep) 13 | 14 | if (BUILD_DEMO) 15 | else () 16 | # Call this from your own project's makefile. 17 | find_package(nng CONFIG REQUIRED) 18 | endif (BUILD_DEMO) 19 | 20 | find_package(Threads) 21 | 22 | if (DEBUG) 23 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 24 | if (ASAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 26 | endif (ASAN) 27 | if (TSAN) 28 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 29 | endif (TSAN) 30 | endif (DEBUG) 31 | 32 | # Uncomment to enable ZeroTier transport 33 | # find_package(zerotiercore) 34 | 35 | add_executable(reqrep reqrep.c) 36 | target_link_libraries(reqrep nng) 37 | target_compile_definitions(reqrep PRIVATE NNG_ELIDE_DEPRECATED) 38 | -------------------------------------------------------------------------------- /demo/rest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Capitar IT Group BV 3 | # Copyright 2018 Staysail Systems, Inc. 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | 10 | cmake_minimum_required(VERSION 3.13) 11 | 12 | project(rest) 13 | 14 | if (BUILD_DEMO) 15 | else () 16 | # Call this from your own project's makefile. 17 | find_package(nng CONFIG REQUIRED) 18 | endif (BUILD_DEMO) 19 | 20 | find_package(Threads) 21 | 22 | if (DEBUG) 23 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 24 | if (ASAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 26 | endif (ASAN) 27 | if (TSAN) 28 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 29 | endif (TSAN) 30 | endif (DEBUG) 31 | 32 | add_executable(rest-server server.c) 33 | target_link_libraries(rest-server nng) 34 | target_compile_definitions(rest-server PRIVATE NNG_ELIDE_DEPRECATED) 35 | -------------------------------------------------------------------------------- /demo/rest/README.adoc: -------------------------------------------------------------------------------- 1 | = REST API Gateway demo 2 | 3 | This is a somewhat contrived demonstration, but may be useful 4 | in a pattern for solving real world problems. 5 | 6 | There is a single "server" (rest-server) program, that does these: 7 | 8 | . REST API at /api/rest/rot13 - this API takes data from HTTP POST commands, 9 | and forwards them to an NNG REQ socket. When the REQ response comes, 10 | the reply is redirected back to the server. (For the purposes of the 11 | demonstration, our server just performs ROT13 on input.) 12 | 13 | . REP server (implemented in the same program using inproc, for demonstration 14 | purposes. In a real world scenario this might instead go to another 15 | process on another computer.) 16 | 17 | [source, bash] 18 | ---- 19 | % env PORT=8888 # default 20 | % ./rest-server & 21 | % curl -d ABC http://127.0.0.1:8888/api/rest/rot13; echo 22 | NOP 23 | % curl -d NOP http://127.0.0.1:8888/api/rest/rot13; echo 24 | ABC 25 | ---- 26 | 27 | == Compiling 28 | 29 | To build the program, we recommend CMake and Ninja-Build. 30 | 31 | [source, bash] 32 | ---- 33 | % mkdir build 34 | % cd build 35 | % cmake -G Ninja .. 36 | % ninja 37 | ---- 38 | 39 | Alternatively, you can go old-school. 40 | Here's the simplest option for Linux: 41 | 42 | [source, bash] 43 | ---- 44 | % cc server.c -o rest-server -I /usr/local/include -lnng 45 | ---- 46 | -------------------------------------------------------------------------------- /demo/stream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Hugo Lindström 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | 9 | cmake_minimum_required(VERSION 3.13) 10 | 11 | project(stream) 12 | 13 | if (BUILD_DEMO) 14 | else () 15 | # Call this from your own project's makefile. 16 | find_package(nng CONFIG REQUIRED) 17 | endif (BUILD_DEMO) 18 | 19 | if (DEBUG) 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") 21 | if (ASAN) 22 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 23 | endif (ASAN) 24 | if (TSAN) 25 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") 26 | endif (TSAN) 27 | endif (DEBUG) 28 | 29 | add_executable(${PROJECT_NAME}) 30 | 31 | target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/stream.c) 32 | 33 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 34 | target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/server.c) 35 | endif() 36 | 37 | if (CMAKE_SYSTEM_NAME MATCHES "Windows") 38 | target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/platform/windows/server.c) 39 | endif() 40 | 41 | target_link_libraries(stream nng) 42 | -------------------------------------------------------------------------------- /docs/LICENSE.adoc: -------------------------------------------------------------------------------- 1 | = The MIT License 2 | 3 | Copyright 2018 Staysail Systems, Inc. + 4 | Copyright 2018 Capitar IT Group BV 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom 11 | the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /docs/README.txt: -------------------------------------------------------------------------------- 1 | This contains the nng documentation for API users. 2 | 3 | The documentation is written in asciidoc in the form of man pages. It is 4 | automatically formatted for display on the website. 5 | 6 | It is possible to emit TROFF sources for use by the UNIX man page, and HTML 7 | for online viewing. asciidoctor supports PDF and EPUB formats via plugins, 8 | so there are still more options available. 9 | 10 | The man pages are in the "man" directory. The reason those are separate 11 | is that they get special treatment. Other documentation is located here. 12 | -------------------------------------------------------------------------------- /docs/man/man1.desc: -------------------------------------------------------------------------------- 1 | This section documents utilities and programs that are included 2 | with the distribution. 3 | -------------------------------------------------------------------------------- /docs/man/man1.sect: -------------------------------------------------------------------------------- 1 | Commands and Utilities 2 | -------------------------------------------------------------------------------- /docs/man/man3.desc: -------------------------------------------------------------------------------- 1 | This section documents core libary functions supporting Scalability 2 | Protocols. 3 | 4 | Most Scalability Protocols applications can be written using just 5 | the functions documented in this section, as this represents the 6 | primary API for building such applications. 7 | -------------------------------------------------------------------------------- /docs/man/man3.sect: -------------------------------------------------------------------------------- 1 | Library Functions 2 | -------------------------------------------------------------------------------- /docs/man/man3compat.desc: -------------------------------------------------------------------------------- 1 | This section documents the _nanomsg_ 1.0 libary compatible functions. 2 | 3 | These functions are provided as a transition aid, for application 4 | developers coming to _NNG_ from _libnanomsg_, and are discouraged 5 | from use in new applications. 6 | 7 | TIP: While this is discouraged for long term use, as a transition aid 8 | applications may use the value returned by the 9 | xref:nng_socket_id.3.adoc[`nng_socket_id()`] in these functions just like a 10 | socket descriptor (as if the socket were opened via 11 | xref:nn_socket.3compat.adoc[`nn_socket()`]). 12 | This sort of API intermixing should only be used during transition from 13 | the legacy API to the new API. 14 | -------------------------------------------------------------------------------- /docs/man/man3compat.sect: -------------------------------------------------------------------------------- 1 | Compatible Library Functions 2 | -------------------------------------------------------------------------------- /docs/man/man3http.desc: -------------------------------------------------------------------------------- 1 | This section documents supplemental HTTP (HyperText Transport Protocol) 2 | support functions that are available. 3 | 4 | These functions can be used in conjunction with the 5 | xref:nng_ws.7.adoc[WebSocket] transport for Scalability Protocols, or they 6 | may be used to construct other types of applications that communicate 7 | using HTTP. 8 | 9 | It is also possible to combine the two, such that an HTTP server providing 10 | static or dynamic content can also be used to host one or more Scalability 11 | Protocols sockets. 12 | 13 | NOTE: At present NNG only supports HTTP/1.0 and HTTP/1.1. 14 | -------------------------------------------------------------------------------- /docs/man/man3http.sect: -------------------------------------------------------------------------------- 1 | Supplemental HTTP Functions 2 | -------------------------------------------------------------------------------- /docs/man/man3str.desc: -------------------------------------------------------------------------------- 1 | This section documents supplemental byte stream functions that 2 | are available. 3 | 4 | These functions are made available to facilitate using raw byte stream 5 | connections with the NNG asynchronous I/O API. 6 | These byte streams may be useful for applications that need to 7 | communicate with raw TCP/IP or IPC streams instead of Scalability Protocols. 8 | -------------------------------------------------------------------------------- /docs/man/man3str.sect: -------------------------------------------------------------------------------- 1 | Supplemental TCP Functions 2 | -------------------------------------------------------------------------------- /docs/man/man3supp.desc: -------------------------------------------------------------------------------- 1 | This section documents supplemental functions that are available. 2 | These functions are not intrinsic to building Scalability Protocols 3 | applications with this library. 4 | 5 | However, their use may facilitate writing portable applications by 6 | providing uniform functions for common application needs such as 7 | mutual exclusion locks, threading, time keeping, and similar needs. 8 | -------------------------------------------------------------------------------- /docs/man/man3supp.sect: -------------------------------------------------------------------------------- 1 | Supplemental Functions 2 | -------------------------------------------------------------------------------- /docs/man/man3tls.desc: -------------------------------------------------------------------------------- 1 | This section documents supplemental TLS (Transport Layer Security) 2 | functions that are available. 3 | TLS support is available when using Scalability Protocols with 4 | the xref:nng_tls.7.adoc[TLS] transport, or when using WebSocket, either 5 | with the xref:nng_ws.7.adoc[WebSocket] transport for Scalability Protocols, 6 | or combined with other HTTP capabilities. 7 | 8 | These functions depend on library support that is not included directly 9 | with _NNG_ however, so their presence will depend on whether this 10 | additional support was present and enabled with _libnng_ was built. 11 | 12 | Currently, this extra support can be provided by the 13 | https://tls.mbed.org[mbedTLS library] or by external plug-ins. 14 | 15 | TIP: Contact https://staysail.tech[Staysail Systems, Inc.] for 16 | details about commercially available options, including support for 17 | FIPS 140-2 validated cryptography and TLS v1.3. 18 | -------------------------------------------------------------------------------- /docs/man/man3tls.sect: -------------------------------------------------------------------------------- 1 | Supplemental TLS Functions 2 | -------------------------------------------------------------------------------- /docs/man/man5.desc: -------------------------------------------------------------------------------- 1 | This section documents core macros and types that are available. 2 | 3 | These are the core types and macros that most Scalabilty Protocols 4 | applications need will use. 5 | -------------------------------------------------------------------------------- /docs/man/man5.sect: -------------------------------------------------------------------------------- 1 | Macros and Types 2 | -------------------------------------------------------------------------------- /docs/man/man7.desc: -------------------------------------------------------------------------------- 1 | This sections documents various protocols and transports that are 2 | available in the distribution. 3 | 4 | (((protocol))) 5 | Protocols implement communication patterns, such as 6 | request/reply, publish/subscribe, and so forth. 7 | A given xref:nng_socket.5.adoc[socket] is created with exactly one protocol, and that 8 | protocol defines the key behavior of the socket. 9 | 10 | (((transport))) 11 | Conversely, transports are the underlying mechansims by which messages 12 | are moved between participants, such as TCP/IP or UNIX domain IPC. 13 | A given xref:nng_socket.5.adoc[socket] may be using several transports at the same 14 | time. 15 | -------------------------------------------------------------------------------- /docs/man/man7.sect: -------------------------------------------------------------------------------- 1 | Protocols and Transports 2 | -------------------------------------------------------------------------------- /docs/man/nn_freemsg.3compat.adoc: -------------------------------------------------------------------------------- 1 | = nn_freemsg(3compat) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nn_freemsg - free message (compatible API) 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nn_freemsg(void *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nn_freemsg()` deallocates a message previously allocated with 28 | xref:nn_allocmsg.3compat.adoc[`nn_allocmsg()`] or similar functions. 29 | 30 | NOTE: This function is provided for API 31 | xref:nng_compat.3compat.adoc[compatibility] with legacy _libnanomsg_. 32 | Consider using the relevant xref:libnng.3.adoc[modern API] instead. 33 | 34 | == RETURN VALUES 35 | 36 | This function always returns 0. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nn_allocmsg.3compat.adoc[nn_allocmsg(3compat)], 46 | xref:nn_freemsg.3compat.adoc[nn_freemsg(3compat)], 47 | xref:nn_errno.3compat.adoc[nn_errno(3compat)], 48 | xref:nng_compat.3compat.adoc[nng_compat(3compat)], 49 | xref:nng.7.adoc[nng(7)] 50 | -------------------------------------------------------------------------------- /docs/man/nn_get_statistic.3compat.adoc: -------------------------------------------------------------------------------- 1 | = nn_get_statistic(3compat) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nn_get_statistic - get statistic (stub) 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | uint64_t nn_get_statistic(int sock, int stat); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nn_get_statistic()` function exists only as a stub, and always returns 28 | zero. 29 | 30 | NOTE: This function is provided for API 31 | xref:nng_compat.3compat.adoc[compatibility] with legacy _libnanomsg_. 32 | Consider using the relevant xref:libnng.3.adoc[modern API] instead. 33 | 34 | == RETURN VALUES 35 | 36 | Zero. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_compat.3compat.adoc[nng_compat(3compat)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nn_strerror.3compat.adoc: -------------------------------------------------------------------------------- 1 | = nn_strerror(3compat) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nn_strerror - return message for error (compatible API) 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | const char *nn_strerror(int err); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nn_strerror()` function returns a human readable message corresponding 28 | to the given error number _err_. 29 | 30 | NOTE: This function is provided for API 31 | xref:nng_compat.3compat.adoc[compatibility] with legacy _libnanomsg_. 32 | Consider using the relevant xref:libnng.3.adoc[modern API] instead. 33 | 34 | == RETURN VALUES 35 | 36 | This function returns the message corresponding to _err_. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nn_errno.3compat.adoc[nn_errno(3compat)], 46 | xref:nng_compat.3compat.adoc[nng_compat(3compat)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_aio_get_msg.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_aio_get_msg(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_aio_get_msg - get message from asynchronous receive 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | nng_msg *nng_aio_get_msg(nng_aio *aio); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_aio_get_msg()` function gets any message stored in _aio_ as 28 | either a result of a successful receive 29 | (see xref:nng_recv_aio.3.adoc[`nng_recv_aio()`]) 30 | or that was previously stored with xref:nng_aio_set_msg.3.adoc[`nng_aio_set_msg()`]. 31 | 32 | IMPORTANT: The xref:nng_aio.5.adoc[`nng_aio`] must not have an operation in progress. 33 | 34 | == RETURN VALUES 35 | 36 | None. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_aio_set_msg.3.adoc[nng_aio_set_msg(3)], 46 | xref:nng_recv_aio.3.adoc[nng_recv_aio(3)], 47 | xref:nng_aio.5.adoc[nng_aio(5)], 48 | xref:nng_msg.5.adoc[nng_msg(5)], 49 | xref:nng.7.adoc[nng(7)] 50 | -------------------------------------------------------------------------------- /docs/man/nng_aio_set_msg.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_aio_set_msg(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_aio_set_msg - set message for asynchronous send 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_aio_set_msg(nng_aio *aio, nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_aio_set_msg()` function sets the message that will be used 28 | for an asynchronous send operation (see xref:nng_send_aio.3.adoc[`nng_send_aio()`]). 29 | 30 | IMPORTANT: The xref:nng_aio.5.adoc[`nng_aio`] must not have an operation in progress. 31 | 32 | == RETURN VALUES 33 | 34 | None. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_aio_get_msg.3.adoc[nng_aio_get_msg(3)], 44 | xref:nng_send_aio.3.adoc[nng_send_aio(3)], 45 | xref:nng_aio.5.adoc[nng_aio(5)], 46 | xref:nng_msg.5.adoc[nng_msg(5)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_cv_free.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_cv_free(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_cv_free - free condition variable 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_cv_free(nng_cv *cv); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_cv_free()` function frees the condition variable _cv_. 28 | 29 | == RETURN VALUES 30 | 31 | None. 32 | 33 | == ERRORS 34 | 35 | None. 36 | 37 | == SEE ALSO 38 | 39 | [.text-left] 40 | xref:nng_cv_alloc.3supp.adoc[nng_cv_alloc(3supp)], 41 | xref:nng.7.adoc[nng(7)] 42 | -------------------------------------------------------------------------------- /docs/man/nng_http_client_free.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_client_free(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_client_free - free HTTP client 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_client_free(nng_http_client *client); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_client_free()` frees the HTTP client and any associated 29 | resources referenced by _client_. 30 | 31 | NOTE: Any connections created by 32 | xref:nng_http_client_connect.3http.adoc[`nng_http_client_connect()`] are unaffected, 33 | and so the caller must close those explicitly if desired. 34 | 35 | == RETURN VALUES 36 | 37 | None. 38 | 39 | == ERRORS 40 | 41 | None. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_http_client_alloc.3http.adoc[nng_http_client_alloc(3)], 47 | xref:nng_http_client_connect.3http.adoc[nng_http_client_connect(3)], 48 | xref:nng.7.adoc[nng(7)] 49 | -------------------------------------------------------------------------------- /docs/man/nng_http_conn_close.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_conn_close(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_conn_close - close HTTP connection 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_conn_close(nng_http_conn *conn); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_conn_close()` function closes the supplied HTTP connection _conn_, 29 | including any disposing of any underlying file descriptors or related resources. 30 | 31 | Once this function, no further access to the _conn_ structure may be made. 32 | 33 | == RETURN VALUES 34 | 35 | None. 36 | 37 | == ERRORS 38 | 39 | None. 40 | 41 | == SEE ALSO 42 | 43 | [.text-left] 44 | xref:nng_http_client_connect.3http.adoc[nng_http_client_connect(3http)], 45 | xref:nng_http_handler_alloc.3http.adoc[nng_http_handler_alloc(3http)], 46 | xref:nng_strerror.3.adoc[nng_strerror(3)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_http_handler_free.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_handler_free(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_handler_free - free HTTP server handler 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_handler_free(nng_http_handler *h); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_handler_free()` function frees an allocated HTTP server handler. 29 | 30 | IMPORTANT: It is an error to free a handler that is registered with a server. 31 | Any handlers that are registered with servers are automatically freed 32 | when the server itself is deallocated. 33 | 34 | == RETURN VALUES 35 | 36 | None. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_http_handler_alloc.3http.adoc[nng_http_handler_alloc(3http)], 46 | xref:nng_http_server_add_handler.3http.adoc[nng_http_server_add_handler(3http)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_http_handler_get_data.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_handler_get_data(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_handler_get_data - return extra data for HTTP handler 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void *nng_http_handler_get_data(nng_http_handler *handler); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_handler_get_data()` function returns the data previously 29 | stored on _handler_ using the function 30 | xref:nng_http_handler_set_data.3http.adoc[`nng_http_handler_set_data()`]. 31 | 32 | == RETURN VALUES 33 | 34 | None. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_http_handler_alloc.3http.adoc[nng_http_handler_alloc(3http)], 44 | xref:nng_http_handler_set_data.3http.adoc[nng_http_server_set_data(3http)], 45 | xref:nng_http_server_add_handler.3http.adoc[nng_http_server_add_handler(3http)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_http_req_free.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_req_free(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_req_free - free HTTP request structure 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_req_free(nng_http_req *req); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_req_free()` function deallocates the HTTP request structure 29 | _req_ entirely. 30 | 31 | TIP: Instead of freeing and reallocating request structures, it is possible 32 | to reuse _req_ with xref:nng_http_req_reset.3http.adoc[`nng_http_req_reset()`]. 33 | 34 | == RETURN VALUES 35 | 36 | None. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_http_req_alloc.3http.adoc[nng_http_req_alloc(3http)], 46 | xref:nng_http_req_reset.3http.adoc[nng_http_req_reset(3http)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_http_req_get_method.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_req_get_method(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_req_get_method - return HTTP request method 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | const char *nng_http_req_get_method(nng_http_req *req); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_req_get_method()` returns the HTTP method associated with 29 | the request _req_. 30 | The value will be a string, such as "GET" or "POST". 31 | 32 | 33 | == RETURN VALUES 34 | 35 | Request method as a string. 36 | 37 | == ERRORS 38 | 39 | None. 40 | 41 | == SEE ALSO 42 | 43 | [.text-left] 44 | xref:nng_http_req_alloc.3http.adoc[nng_http_req_alloc(3http)], 45 | xref:nng_http_req_set_method.3http.adoc[nng_http_req_set_method(3http)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_http_req_get_uri.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_req_get_uri(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_req_get_uri - return HTTP request URI 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | const char *nng_http_req_get_uri(nng_http_req *req); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_req_get_uri()` returns the URI (path) associated with the HTTP 29 | request _req_. 30 | The value returned includes the path, as well as any query information or 31 | fragment. The value will look like a file system path 32 | with those optional components appended, such as `/api/get_info.cgi?name=garrett`. 33 | 34 | == RETURN VALUES 35 | 36 | Request URI as a string. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_http_req_alloc.3http.adoc[nng_http_req_alloc(3http)], 46 | xref:nng_http_req_set_uri.3http.adoc[nng_http_req_set_uri(3http)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_http_req_get_version.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_req_get_version(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_req_get_version - return HTTP request protocol version 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | const char *nng_http_req_get_version(nng_http_req *req); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_req_get_version()` returns a string representing the HTTP 29 | protocol version associated with the request _req_, such as "HTTP/1.1". 30 | 31 | 32 | == RETURN VALUES 33 | 34 | Request version as a string. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_http_req_alloc.3http.adoc[nng_http_req_alloc(3http)], 44 | xref:nng_http_req_set_version.3http.adoc[nng_http_req_set_version(3http)], 45 | xref:nng.7.adoc[nng(7)] 46 | -------------------------------------------------------------------------------- /docs/man/nng_http_req_reset.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_req_reset(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_req_reset - reset HTTP request structure 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_req_reset(nng_http_req *req); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_req_reset()` function resets the request __req__ so that it 29 | is just as if it had been freshly allocated with 30 | xref:nng_http_req_alloc.3http.adoc[`nng_http_req_alloc()`] with a `NULL` URL. 31 | 32 | NOTE: Before using this with an HTTP operation, the URI must be set using 33 | xref:nng_http_req_set_uri.3http.adoc[`nng_http_req_set_uri()`]. 34 | 35 | == RETURN VALUES 36 | 37 | None. 38 | 39 | == ERRORS 40 | 41 | None. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_http_req_alloc.3http.adoc[nng_http_req_alloc(3http)], 47 | xref:nng_http_req_set_uri.3http.adoc[nng_http_req_set_uri(3http)], 48 | xref:nng.7.adoc[nng(7)] 49 | -------------------------------------------------------------------------------- /docs/man/nng_http_res_free.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_res_free(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_res_free - free HTTP response structure 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_res_free(nng_http_res *req); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_res_free()` function deallocates the HTTP response structure 29 | _res_ entirely. 30 | 31 | TIP: Instead of freeing and reallocating response structures, it is possible 32 | to reuse _res_ with xref:nng_http_res_reset.3http.adoc[`nng_http_res_reset()`]. 33 | 34 | == RETURN VALUES 35 | 36 | None. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_http_res_alloc.3http.adoc[nng_http_res_alloc(3http)], 46 | xref:nng_http_res_reset.3http.adoc[nng_http_res_reset(3http)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_http_res_get_version.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_res_get_version(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_res_get_version - return HTTP response protocol version 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | const char *nng_http_res_get_version(nng_http_res *res); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_res_get_version()` returns a string representing the HTTP 29 | protocol version associated with the request _res_, such as "HTTP/1.1". 30 | 31 | 32 | == RETURN VALUES 33 | 34 | Response version as a string. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_http_res_alloc.3http.adoc[nng_http_res_alloc(3http)], 44 | xref:nng_http_res_set_version.3http.adoc[nng_http_res_set_version(3http)], 45 | xref:nng.7.adoc[nng(7)] 46 | -------------------------------------------------------------------------------- /docs/man/nng_http_res_reset.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_res_reset(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_res_reset - reset HTTP response structure 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_http_res_reset(nng_http_res *res); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_http_res_reset()` function resets the response __res__ so that it 29 | is just as if it had been freshly allocated with 30 | xref:nng_http_res_alloc.3http.adoc[`nng_http_res_alloc()`]. 31 | 32 | == RETURN VALUES 33 | 34 | None. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_http_res_alloc.3http.adoc[nng_http_res_alloc(3http)], 44 | xref:nng.7.adoc[nng(7)] 45 | -------------------------------------------------------------------------------- /docs/man/nng_http_server_get_addr.3http.adoc: -------------------------------------------------------------------------------- 1 | = nng_http_server_get_addr(3http) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_http_server_get_addr - get HTTP server address 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | int nng_http_server_get_addr(nng_http_server *server, nng_sockaddr *sap); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | `nng_http_server_get_addr()`:: 29 | This function is used to retrieve an xref:nng_sockaddr.5.adoc[`nng_sockaddr`] 30 | into the value referenced by _sap_ for the server _server_. 31 | 32 | == RETURN VALUES 33 | 34 | This function returns 0 on success, and non-zero otherwise. 35 | 36 | == ERRORS 37 | 38 | `NNG_EINVAL`:: Either _server_ or _sap_ parameter is NULL. 39 | `NNG_ENOTSUP`:: HTTP not supported. 40 | 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_sockaddr.5.adoc[nng_sockaddr(5)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_inproc_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_inproc_register(3) 2 | // 3 | // Copyright 2021 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_inproc_register - register inproc transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_inproc_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_inproc_register()` function registers the 28 | ((_inproc_ transport))(((transport, _inproc_))) for use. 29 | 30 | NOTE: This function is deprecated, and may be removed from a future release. 31 | It is no longer necessary to explicitly register transports. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns 0 on success, and non-zero otherwise. 36 | 37 | == ERRORS 38 | 39 | [horizontal] 40 | `NNG_ENOMEM`:: Insufficient memory is available. 41 | `NNG_ENOTSUP`:: The transport is not supported. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_inproc.7.adoc[nng_inproc(5)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_ipc_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_ipc_register(3) 2 | // 3 | // Copyright 2021 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_ipc_register - register ipc transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_ipc_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_ipc_register()` function registers the 28 | ((_ipc_ transport))(((transport, _ipc_))) for use. 29 | 30 | NOTE: This function is deprecated, and may be removed from a future release. 31 | It is no longer necessary to explicitly register transports. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns 0 on success, and non-zero otherwise. 36 | 37 | == ERRORS 38 | 39 | [horizontal] 40 | `NNG_ENOMEM`:: Insufficient memory is available. 41 | `NNG_ENOTSUP`:: The transport is not supported. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_ipc.7.adoc[nng_ipc(5)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_log_get_level.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_log_get_level(3) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // 5 | // This document is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | == NAME 12 | 13 | nng_log_get_level - get minimum level for logging messagse 14 | 15 | == SYNOPSIS 16 | 17 | [source, c] 18 | ---- 19 | #include 20 | 21 | typedef enum nng_log_level { 22 | NNG_LOG_NONE = 0, // used for filters only, NNG suppresses these 23 | NNG_LOG_ERR = 3, 24 | NNG_LOG_WARN = 4, 25 | NNG_LOG_NOTICE = 5, 26 | NNG_LOG_INFO = 6, 27 | NNG_LOG_DEBUG = 7 28 | } nng_log_level; 29 | 30 | nng_log_level nng_log_set_level(void); 31 | ---- 32 | 33 | == DESCRIPTION 34 | 35 | The `nng_log_get_level` function is used to get the minimum severity to _level_ for processing log messages. 36 | The intended use case is to avoid expensive operations used solely to provide debugging information in logs, 37 | if the logged content would merely be discarded. 38 | 39 | == SEE ALSO 40 | 41 | xref:nng_log_set_facility.3.adoc[nng_log_set_facility(3)], 42 | xref:nng_log_set_level.3.adoc[nng_log_set_level(3)] 43 | -------------------------------------------------------------------------------- /docs/man/nng_log_set_level.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_log_set_level(3) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // 5 | // This document is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | == NAME 12 | 13 | nng_log_set_level - set minimum level for logging messagse 14 | 15 | == SYNOPSIS 16 | 17 | [source, c] 18 | ---- 19 | #include 20 | 21 | typedef enum nng_log_level { 22 | NNG_LOG_NONE = 0, // used for filters only, NNG suppresses these 23 | NNG_LOG_ERR = 3, 24 | NNG_LOG_WARN = 4, 25 | NNG_LOG_NOTICE = 5, 26 | NNG_LOG_INFO = 6, 27 | NNG_LOG_DEBUG = 7 28 | } nng_log_level; 29 | 30 | void nng_log_set_level(nng_log_level level); 31 | ---- 32 | 33 | == DESCRIPTION 34 | 35 | The `nng_log_set_level` function is used to set the minimum severity to _level_ for processing log messages. 36 | Any messages with a less severe rating are not processed and simply are discarded. 37 | Use `NNG_LOG_NONE` to suppress all log messages. 38 | Use `NNG_LOG_DEBUG` to receive all log messages. 39 | 40 | == SEE ALSO 41 | 42 | xref:nng_log_get_level.3.adoc[nng_log_set_level(3)] 43 | xref:nng_log_set_facility.3.adoc[nng_log_set_facility(3)] 44 | -------------------------------------------------------------------------------- /docs/man/nng_msg_capacity.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_capacity(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_capacity - return message body length 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | size_t nng_msg_capacity(nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_capacity()` returns the storage allocated for the body of message _msg_. 28 | The capacity includes the current contents of the message and free space after it. 29 | The message body may grow to capacity without performing any further allocations. 30 | 31 | == RETURN VALUES 32 | 33 | Allocated capacity for message body. 34 | 35 | == ERRORS 36 | 37 | None. 38 | 39 | == SEE ALSO 40 | 41 | [.text-left] 42 | xref:nng_msg_reserve.3.adoc[nng_msg_reserve(3)], 43 | xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], 44 | xref:nng_msg_body.3.adoc[nng_msg_body(3)], 45 | xref:nng_msg.5.adoc[nng_msg(5)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_msg_clear.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_clear(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_clear - clear message body content 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_msg_clear(nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_clear()` function resets the body length of _msg_ to zero. 28 | 29 | == RETURN VALUES 30 | 31 | None. 32 | 33 | == ERRORS 34 | 35 | None. 36 | 37 | == SEE ALSO 38 | 39 | [.text-left] 40 | xref:nng_msg.5.adoc[nng_msg(5)], 41 | xref:nng.7.adoc[nng(7)] 42 | -------------------------------------------------------------------------------- /docs/man/nng_msg_free.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_free(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_free - free a message 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_msg_free(nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_free()` function deallocates the message _msg_ entirely. 28 | 29 | == RETURN VALUES 30 | 31 | None. 32 | 33 | == ERRORS 34 | 35 | None. 36 | 37 | == SEE ALSO 38 | 39 | [.text-left] 40 | xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], 41 | xref:nng_msg_realloc.3.adoc[nng_msg_realloc(3)], 42 | xref:nng_msg.5.adoc[nng_msg(5)], 43 | xref:nng.7.adoc[nng(7)] 44 | -------------------------------------------------------------------------------- /docs/man/nng_msg_header_clear.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_header_clear(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_header_clear - clear message header 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_msg_header_clear(nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_clear()` function resets the header length of _msg_ to zero. 28 | 29 | == RETURN VALUES 30 | 31 | None. 32 | 33 | == ERRORS 34 | 35 | None. 36 | 37 | == SEE ALSO 38 | 39 | [.text-left] 40 | xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], 41 | xref:nng_msg_free.3.adoc[nng_msg_free(3)], 42 | xref:nng.7.adoc[nng(7)] 43 | -------------------------------------------------------------------------------- /docs/man/nng_msg_header_len.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_header_len(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_header_len - return message header length 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | size_t nng_msg_header_len(nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_header_len()` returns the length of message header of _msg_. 28 | 29 | == RETURN VALUES 30 | 31 | Length of message header. 32 | 33 | == ERRORS 34 | 35 | None. 36 | 37 | == SEE ALSO 38 | 39 | [.text-left] 40 | xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], 41 | xref:nng_msg_header.3.adoc[nng_msg_header(3)], 42 | xref:nng_msg.5.adoc[nng_msg(5)], 43 | xref:nng.7.adoc[nng(7)] 44 | -------------------------------------------------------------------------------- /docs/man/nng_msg_len.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_len(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_len - return message body length 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | size_t nng_msg_len(nng_msg *msg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_len()` returns the length of the body of message _msg_. 28 | 29 | == RETURN VALUES 30 | 31 | Length of message body. 32 | 33 | == ERRORS 34 | 35 | None. 36 | 37 | == SEE ALSO 38 | 39 | [.text-left] 40 | xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], 41 | xref:nng_msg_body.3.adoc[nng_msg_body(3)], 42 | xref:nng_msg.5.adoc[nng_msg(5)], 43 | xref:nng.7.adoc[nng(7)] 44 | -------------------------------------------------------------------------------- /docs/man/nng_msg_set_pipe.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_msg_set_pipe(3) 2 | // 3 | // Copyright 2019 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msg_set_pipe - set pipe for message 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_msg_set_pipe(nng_msg *msg, nng_pipe p); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msg_set_pipe()` sets the pipe associated with message _m_ to _p_. 28 | This is most often useful when used with protocols that support directing 29 | a message to a specific peer. 30 | For example the xref:nng_pair.7.adoc[_pair_] version 1 protocol can do 31 | this when `NNG_OPT_PAIR1_POLY` mode is set. 32 | 33 | NOTE: Not all protocols support overriding the destination pipe. 34 | 35 | == RETURN VALUES 36 | 37 | None. 38 | 39 | == ERRORS 40 | 41 | None. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], 47 | xref:nng_msg_get_pipe.3.adoc[nng_msg_get_pipe(3)], 48 | xref:nng_pipe_getopt.3.adoc[nng_pipe_getopt(3)], 49 | xref:nng_msg.5.adoc[nng_msg(5)], 50 | xref:nng.7.adoc[nng(7)] 51 | -------------------------------------------------------------------------------- /docs/man/nng_msleep.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_msleep(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_msleep - sleep milliseconds 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_msleep(nng_duration msec); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_msleep()` blocks the caller for at least _msec_ milliseconds. 28 | 29 | NOTE: This function may block for longer than requested. 30 | The actual wait time is determined by the capabilities of the 31 | underlying system. 32 | 33 | == RETURN VALUES 34 | 35 | None. 36 | 37 | == ERRORS 38 | 39 | None. 40 | 41 | == SEE ALSO 42 | 43 | [.text-left] 44 | xref:nng_sleep_aio.3.adoc[nng_sleep_aio(3)], 45 | xref:nng_strerror.3.adoc[nng_strerror(3)], 46 | xref:nng_clock.3supp.adoc[nng_clock(3supp)], 47 | xref:nng_duration.5.adoc[nng_duration(5)], 48 | xref:nng.7.adoc[nng(7)] 49 | -------------------------------------------------------------------------------- /docs/man/nng_mtx_free.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_mtx_free(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_mtx_free - free mutex 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_mtx_free(nng_mtx *mtx); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_mtx_free()` function frees the mutex _mtx_. 28 | The mutex must not be locked when this function is called. 29 | 30 | == RETURN VALUES 31 | 32 | None. 33 | 34 | == ERRORS 35 | 36 | None. 37 | 38 | == SEE ALSO 39 | 40 | [.text-left] 41 | xref:nng_mtx_alloc.3supp.adoc[nng_mtx_alloc(3supp)], 42 | xref:nng.7.adoc[nng(7)] 43 | -------------------------------------------------------------------------------- /docs/man/nng_mtx_unlock.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_mtx_unlock(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_mtx_unlock - unlock mutex 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_mtx_unlock(nng_mtx *mtx); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_mtx_unlock()` relinquishes ownership of the mutex _mtx_ that 28 | was previously acquired via xref:nng_mtx_lock.3supp.adoc[`nng_mtx_lock()`]. 29 | 30 | IMPORTANT: A mutex can _only_ be unlocked by the thread that locked it. 31 | Attempting to unlock a mutex that is not owned by the caller will result 32 | in undefined behavior. 33 | 34 | == RETURN VALUES 35 | 36 | None. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_mtx_alloc.3supp.adoc[nng_mtx_alloc(3supp)], 46 | xref:nng_mtx_lock.3supp.adoc[nng_mtx_lock(3supp)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_pipe_dialer.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_pipe_dialer(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_pipe_dialer - return dialer that created pipe 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | nng_dialer nng_pipe_dialer(nng_pipe p); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_pipe_dialer()` function returns the xref:nng_dialer.5.adoc[`nng_dialer`] 28 | that created the pipe _p_. 29 | If the pipe was not created by a dialer, then the returned value will 30 | have an identifier (xref:nng_dialer_id.3.adoc[`nng_dialer_id()`]) of `-1`. 31 | 32 | == RETURN VALUES 33 | 34 | This function returns the dialer that created the pipe, unless it was 35 | not created by a dialer, in which case a value initialized with 36 | `NNG_DIALER_INITIALIZER` will be returned. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_pipe.5.adoc[nng_pipe(5)], 46 | xref:nng_dialer.5.adoc[nng_dialer(5)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_pipe_id.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_pipe_id(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_pipe_id - return numeric pipe identifier 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | int nng_pipe_id(nng_pipe p); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_pipe_id()` function returns a positive identifier for the pipe _p_, 28 | if it is valid. 29 | Otherwise it returns `-1`. 30 | 31 | NOTE: A pipe is considered valid if it was ever created by the socket. 32 | Pipes that are allocated on the stack or statically should be 33 | initialized with the macro 34 | xref:nng_pipe.5.adoc#NNG_PIPE_INITIALIZER[`NNG_PIPE_INITIALIZER`] to ensure that 35 | they cannot be confused with a valid pipe. 36 | 37 | == RETURN VALUES 38 | 39 | This function returns the positive value for the pipe identifier, or 40 | `-1` if the pipe is invalid. 41 | 42 | == ERRORS 43 | 44 | None. 45 | 46 | == SEE ALSO 47 | 48 | [.text-left] 49 | xref:nng_pipe.5.adoc[nng_pipe(5)], 50 | xref:nng.7.adoc[nng(7)] 51 | -------------------------------------------------------------------------------- /docs/man/nng_pipe_listener.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_pipe_listener(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_pipe_listener - return listener that created pipe 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | nng_listener nng_pipe_listener(nng_pipe p); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_pipe_listener()` function returns the xref:nng_listener.5.adoc[`nng_listener`] 28 | that created the pipe _p_. 29 | If the pipe was not created by a listener, then the returned value will 30 | have an identifier (xref:nng_listener_id.3.adoc[`nng_listener_id()`]) of `-1`. 31 | 32 | == RETURN VALUES 33 | 34 | This function returns the listener that created the pipe, unless it was 35 | not created by a listener, in which case a value initialized with 36 | `NNG_LISTENER_INITIALIZER` will be returned. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_pipe.5.adoc[nng_pipe(5)], 46 | xref:nng_listener.5.adoc[nng_listener(5)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_pipe_socket.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_pipe_socket(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_pipe_socket - return owning socket for pipe 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | nng_socket nng_pipe_socket(nng_pipe p); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_pipe_socket()` function returns the xref:nng_socket.5.adoc[`nng_socket`] 28 | associated with the pipe _p_. 29 | 30 | NOTE: The returned socket may be closed or in the process of closing, in 31 | which case it will not be usable with other functions. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns the socket associated with the pipe. 36 | 37 | == ERRORS 38 | 39 | None. 40 | 41 | == SEE ALSO 42 | 43 | [.text-left] 44 | xref:nng_pipe.5.adoc[nng_pipe(5)], 45 | xref:nng_socket.5.adoc[nng_socket(5)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_random.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_random(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_random - get random number 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | uint32_t nng_random(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_random()` returns a random number. 28 | The value is obtained using platform specific cryptographically strong random 29 | number facilities when available. 30 | 31 | == RETURN VALUES 32 | 33 | Random number. 34 | 35 | == ERRORS 36 | 37 | None. 38 | 39 | == SEE ALSO 40 | 41 | [.text-left] 42 | xref:nng.7.adoc[nng(7)] 43 | -------------------------------------------------------------------------------- /docs/man/nng_stat_child.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_stat_child(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_stat_child - get child statistic 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | typedef struct nng_stat nng_stat; 23 | 24 | nng_stat *nng_stat_child(nng_stat *parent); 25 | ---- 26 | 27 | == DESCRIPTION 28 | 29 | The `nng_stat_child()` function returns the first child statistic of the 30 | statistic _parent_. 31 | If no children are present, then `NULL` is returned. 32 | 33 | TIP: Only statistics with type (see xref:nng_stat_type.3.adoc[`nng_stat_type()`]) 34 | of `NNG_STAT_SCOPE` will have children. 35 | 36 | == RETURN VALUES 37 | 38 | The first child statistic of _parent_, or NULL if _parent_ has no children. 39 | 40 | == ERRORS 41 | 42 | None. 43 | 44 | == SEE ALSO 45 | 46 | [.text-left] 47 | xref:libnng.3.adoc[libnng(3)], 48 | xref:nng_stat_next.3.adoc[nng_stat_next(3)], 49 | xref:nng_stats_get.3.adoc[nng_stats_get(3)], 50 | xref:nng_stat.5.adoc[nng_stat(5)], 51 | xref:nng.7.adoc[nng(7)] 52 | -------------------------------------------------------------------------------- /docs/man/nng_stat_desc.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_stat_desc(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_stat_desc - get statistic description 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | typedef struct nng_stat nng_stat; 23 | 24 | const char *nng_stat_desc(nng_stat *stat); 25 | ---- 26 | 27 | == DESCRIPTION 28 | 29 | The `nng_stat_desc()` function returns a brief, human-readable description 30 | for the statistic _stat_. 31 | 32 | TIP: This description can be used for a tool-tip in user interfaces 33 | displaying these statistic values. 34 | 35 | NOTE: At this time, only English descriptions are provided. 36 | 37 | == RETURN VALUES 38 | 39 | The description of statistic _stat_. 40 | 41 | == ERRORS 42 | 43 | None. 44 | 45 | == SEE ALSO 46 | 47 | [.text-left] 48 | xref:libnng.3.adoc[libnng(3)], 49 | xref:nng_stat_name.3.adoc[nng_stats_name(3)], 50 | xref:nng_stats_get.3.adoc[nng_stats_get(3)], 51 | xref:nng_stat.5.adoc[nng_stat(5)], 52 | xref:nng.7.adoc[nng(7)] 53 | -------------------------------------------------------------------------------- /docs/man/nng_stat_name.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_stat_name(3) 2 | 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | 11 | == NAME 12 | 13 | nng_stat_name - get statistic name 14 | 15 | == SYNOPSIS 16 | 17 | [source, c] 18 | ---- 19 | #include 20 | 21 | typedef struct nng_stat nng_stat; 22 | 23 | const char *nng_stat_name(nng_stat *stat); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_stat_name()` function returns the name for the statistic _stat_. 29 | 30 | NOTE: The global root statistic will have the empty string ("") as it's name. 31 | 32 | == RETURN VALUES 33 | 34 | The name of statistic _stat_. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:libnng.3.adoc[libnng(3)], 44 | xref:nng_stats_get.3.adoc[nng_stats_get(3)], 45 | xref:nng_stat.5.adoc[nng_stat(5)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_stat_next.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_stat_next(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_stat_next - get next statistic 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | typedef struct nng_stat nng_stat; 23 | 24 | nng_stat *nng_stat_next(nng_stat *stat); 25 | ---- 26 | 27 | == DESCRIPTION 28 | 29 | The `nng_stat_next()` function returns the next sibling statistic of the 30 | statistic _stat_. 31 | If no more siblings are present, then `NULL` is returned. 32 | 33 | == RETURN VALUES 34 | 35 | The next sibling statistic of _stat_, or NULL if _stat_ is the last sibling. 36 | 37 | == ERRORS 38 | 39 | None. 40 | 41 | == SEE ALSO 42 | 43 | [.text-left] 44 | xref:libnng.3.adoc[libnng(3)], 45 | xref:nng_stat_child.3.adoc[nng_stat_child(3)], 46 | xref:nng_stats_get.3.adoc[nng_stats_get(3)], 47 | xref:nng_stat.5.adoc[nng_stat(5)], 48 | xref:nng.7.adoc[nng(7)] 49 | -------------------------------------------------------------------------------- /docs/man/nng_stats_free.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_stats_free(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_stats_free - free statistics snapshot 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | typedef nng_stat nng_stat; 23 | 24 | void nng_stats_free(nng_stat *); 25 | ---- 26 | 27 | == DESCRIPTION 28 | 29 | The `nng_stats_free()` function deallocates a statistics snapshot 30 | previously collected with 31 | xref:nng_stats_get.3.adoc[`nng_stats_get()`]. 32 | After calling this, all values associated with the snapshot are 33 | invalidated. 34 | 35 | IMPORTANT: Only the top of the collected statistics tree can be 36 | freed using this function. 37 | 38 | == RETURN VALUES 39 | 40 | None. 41 | 42 | == ERRORS 43 | 44 | None. 45 | 46 | == SEE ALSO 47 | 48 | [.text-left] 49 | xref:nng_stats_get.3.adoc[nng_stats_get(3)], 50 | xref:nng_stat.5.adoc[nng_stat(5)], 51 | xref:nng.7.adoc[nng(7)] 52 | -------------------------------------------------------------------------------- /docs/man/nng_tcp_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_tcp_register(3) 2 | // 3 | // Copyright 2021 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_tcp_register - register tcp transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_tcp_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_tcp_register()` function registers the 28 | ((_tcp_ transport))(((transport, _tcp_))) for use. 29 | 30 | NOTE: This function is deprecated, and may be removed from a future release. 31 | It is no longer necessary to explicitly register transports. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns 0 on success, and non-zero otherwise. 36 | 37 | == ERRORS 38 | 39 | [horizontal] 40 | `NNG_ENOMEM`:: Insufficient memory is available. 41 | `NNG_ENOTSUP`:: The transport is not supported. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_tcp.7.adoc[nng_tcp(7)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_thread_destroy.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_thread_destroy(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_thread_destroy - reap thread 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_thread_destroy(nng_thread *thread); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_thread_destroy()` function reaps the _thread_. 28 | It waits for the thread function to return, and then deallocates 29 | the resources for the thread. 30 | 31 | IMPORTANT: Do not call this function from the thread function itself, 32 | or a deadlock will occur. 33 | 34 | == RETURN VALUES 35 | 36 | None. 37 | 38 | == ERRORS 39 | 40 | None. 41 | 42 | == SEE ALSO 43 | 44 | [.text-left] 45 | xref:nng_thread_create.3supp.adoc[nng_thread_create(3supp)], 46 | xref:nng.7.adoc[nng(7)] 47 | -------------------------------------------------------------------------------- /docs/man/nng_thread_set_name.3supp.adoc: -------------------------------------------------------------------------------- 1 | = nng_thread_set_name(3supp) 2 | // 3 | // Copyright 2024 Staysail Systems, Inc. 4 | // 5 | // This document is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | == NAME 12 | 13 | nng_thread_set_name - set thread name 14 | 15 | == SYNOPSIS 16 | 17 | [source, c] 18 | ---- 19 | #include 20 | 21 | void nng_thread_set_name(nng_thread *thread, const char *name); 22 | ---- 23 | 24 | == DESCRIPTION 25 | 26 | The `nng_thread_set_name()` function attempts to set the name for the _thread_ to _name_. 27 | 28 | If _thread_ is `NULL`, then the name is set for the current thread. 29 | 30 | Support for this, and how names are exposed, varies between platform implementations. 31 | This function is intended to facilitate debugging applications that may have many threads. 32 | 33 | TIP: Internal threads created by _NNG_ will have names beginning with `nng:`. 34 | 35 | == RETURN VALUES 36 | 37 | None. 38 | 39 | == ERRORS 40 | 41 | None. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_thread_create.3supp.adoc[nng_thread_create(3supp)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_tls_config_free.3tls.adoc: -------------------------------------------------------------------------------- 1 | = nng_tls_config_free(3tls) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_tls_config_free - deallocate a TLS configuration object 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | #include 22 | 23 | void nng_tls_config_free(nng_tls_config *cfg); 24 | ---- 25 | 26 | == DESCRIPTION 27 | 28 | The `nng_tls_config_free()` decrements the reference count on the 29 | TLS configuration object pointed to by _cfg_, and if the resulting 30 | reference count is zero, then deallocates the configuration object. 31 | 32 | == RETURN VALUES 33 | 34 | None. 35 | 36 | == ERRORS 37 | 38 | None. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_tls_config_alloc.3tls.adoc[nng_tls_config_alloc(3tls)], 44 | xref:nng.7.adoc[nng(7)] 45 | -------------------------------------------------------------------------------- /docs/man/nng_tls_config_hold.3tls.adoc: -------------------------------------------------------------------------------- 1 | = nng_tls_config_hold(3tls) 2 | // 3 | // Copyright 2019 Staysail Systems, Inc. 4 | // 5 | // This document is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | == NAME 12 | 13 | nng_tls_config_hold - hold TLS configuration object 14 | 15 | == SYNOPSIS 16 | 17 | [source, c] 18 | ---- 19 | #include 20 | #include 21 | 22 | void nng_tls_config_alloc(nng_tls_config *cfg); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_tls_config_hold()` increments the reference count on 28 | the configuration object named by _cfg_, thereby preventing it 29 | from being freed while in use. 30 | 31 | The hold can be released by calling 32 | xref:nng_tls_config_free.3tls.adoc[`nng_tls_config_free()`]. 33 | 34 | Multiple holds can be placed on a configuration object; the object 35 | will not be freed until the last hold is released. 36 | 37 | == RETURN VALUES 38 | 39 | None. 40 | 41 | == ERRORS 42 | 43 | None. 44 | 45 | == SEE ALSO 46 | 47 | [.text-left] 48 | xref:nng_tls_config_alloc.3tls.adoc[nng_tls_config_alloc(3tls)], 49 | xref:nng_tls_config_free.3tls.adoc[nng_tls_config_free(3tls)], 50 | xref:nng.7.adoc[nng(7)] 51 | -------------------------------------------------------------------------------- /docs/man/nng_tls_engine_description.3tls.adoc: -------------------------------------------------------------------------------- 1 | = nng_tls_engine_description(3tls) 2 | // 3 | // Copyright 2020 Staysail Systems, Inc. 4 | // 5 | // This document is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | == NAME 12 | 13 | nng_tls_engine_description - TLS engine description 14 | 15 | == SYNOPSIS 16 | 17 | [source,c] 18 | ---- 19 | #include 20 | 21 | const char *nng_tls_engine_description(void); 22 | ---- 23 | 24 | == DESCRIPTION 25 | 26 | The `nng_tls_engine_description()` returns a short description for the current 27 | xref:nng_tls_engine.5.adoc[TLS engine]. 28 | If no engine is registered, then the empty string ("") is returned. 29 | This is principally useful for diagnostic purposes. 30 | 31 | == RETURN VALUES 32 | 33 | The description of the engine of the engine. 34 | 35 | == ERRORS 36 | 37 | None. 38 | 39 | == SEE ALSO 40 | 41 | [.text-left] 42 | xref:nng_tls_engine_name.3tls.adoc[nng_tls_engine_name(3tls)], 43 | xref:nng_tls_engine.5.adoc[nng_tls_engine(5)], 44 | xref:nng.7.adoc[nng(7)] 45 | -------------------------------------------------------------------------------- /docs/man/nng_tls_engine_name.3tls.adoc: -------------------------------------------------------------------------------- 1 | = nng_tls_engine_name(3tls) 2 | // 3 | // Copyright 2020 Staysail Systems, Inc. 4 | // 5 | // This document is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | == NAME 12 | 13 | nng_tls_engine_name - TLS engine name 14 | 15 | == SYNOPSIS 16 | 17 | [source,c] 18 | ---- 19 | #include 20 | 21 | const char *nng_tls_engine_name(void); 22 | ---- 23 | 24 | == DESCRIPTION 25 | 26 | The `nng_tls_engine_name()` returns a short name for the current 27 | xref:nng_tls_engine.5.adoc[TLS engine]. 28 | If no engine is registered, then the special name "none" is returned. 29 | 30 | == RETURN VALUES 31 | 32 | The name of the engine. 33 | 34 | == ERRORS 35 | 36 | None. 37 | 38 | == SEE ALSO 39 | 40 | [.text-left] 41 | xref:nng_tls_engine_description.3tls.adoc[nng_tls_engine_description(3tls)], 42 | xref:nng_tls_engine.5.adoc[nng_tls_engine(5)] 43 | xref:nng.7.adoc[nng(7)] 44 | -------------------------------------------------------------------------------- /docs/man/nng_tls_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_tls_register(3) 2 | // 3 | // Copyright 2018 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_tls_register - register tls transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_tls_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_tls_register()` function registers the 28 | ((_tls_ transport))(((transport, _tls_))) for use. 29 | 30 | == RETURN VALUES 31 | 32 | This function returns 0 on success, and non-zero otherwise. 33 | 34 | == ERRORS 35 | 36 | [horizontal] 37 | `NNG_ENOMEM`:: Insufficient memory is available. 38 | `NNG_ENOTSUP`:: The transport is not supported. 39 | 40 | == SEE ALSO 41 | 42 | [.text-left] 43 | xref:nng_tls.7.adoc[nng_tls(7)], 44 | xref:nng.7.adoc[nng(7)] 45 | -------------------------------------------------------------------------------- /docs/man/nng_url_free.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_url_free(3) 2 | // 3 | // Copyright 2020 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_url_free - free a URL structure 15 | 16 | == SYNOPSIS 17 | 18 | [source, c] 19 | ---- 20 | #include 21 | 22 | void nng_url_free(nng_url *url); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_url_free()` function deallocates the _url_ entirely, including 28 | any of its members. 29 | 30 | == RETURN VALUES 31 | 32 | None. 33 | 34 | == ERRORS 35 | 36 | None. 37 | 38 | == SEE ALSO 39 | 40 | [.text-left] 41 | xref:nng_url_clone.3.adoc[nng_url_clone(3)], 42 | xref:nng_url_parse.3.adoc[nng_url_parse(3)], 43 | xref:nng_url.5.adoc[nng_url(5)], 44 | xref:nng.7.adoc[nng(7)] 45 | -------------------------------------------------------------------------------- /docs/man/nng_ws_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_ws_register(3) 2 | // 3 | // Copyright 2021 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_ws_register - register WebSocket transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_ws_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_ws_register()` function registers the 28 | ((_ws_ transport))(((transport, _ws_))) for use. 29 | 30 | NOTE: This function is deprecated, and may be removed from a future release. 31 | It is no longer necessary to explicitly register transports. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns 0 on success, and non-zero otherwise. 36 | 37 | == ERRORS 38 | 39 | [horizontal] 40 | `NNG_ENOMEM`:: Insufficient memory is available. 41 | `NNG_ENOTSUP`:: The transport is not supported. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_ws.7.adoc[nng_ws(7)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_wss_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_wss_register(3) 2 | // 3 | // Copyright 2021 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_wss_register - register WebSocket secure transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_wss_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_wss_register()` function registers the 28 | ((_wss_ transport))(((transport, _wss_))) for use. 29 | 30 | NOTE: This function is deprecated, and may be removed from a future release. 31 | It is no longer necessary to explicitly register transports. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns 0 on success, and non-zero otherwise. 36 | 37 | == ERRORS 38 | 39 | [horizontal] 40 | `NNG_ENOMEM`:: Insufficient memory is available. 41 | `NNG_ENOTSUP`:: The transport is not supported. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_ws.7.adoc[nng_ws(7)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /docs/man/nng_zt_register.3.adoc: -------------------------------------------------------------------------------- 1 | = nng_zt_register(3) 2 | // 3 | // Copyright 2021 Staysail Systems, Inc. 4 | // Copyright 2018 Capitar IT Group BV 5 | // 6 | // This document is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | == NAME 13 | 14 | nng_zt_register - register ZeroTier transport 15 | 16 | == SYNOPSIS 17 | 18 | [source,c] 19 | ---- 20 | #include 21 | 22 | int nng_zt_register(void); 23 | ---- 24 | 25 | == DESCRIPTION 26 | 27 | The `nng_zt_register()` function registers the 28 | ((_zt_ transport))(((transport, _zt_))) for use. 29 | 30 | NOTE: This function is deprecated, and may be removed from a future release. 31 | It is no longer necessary to explicitly register transports. 32 | 33 | == RETURN VALUES 34 | 35 | This function returns 0 on success, and non-zero otherwise. 36 | 37 | == ERRORS 38 | 39 | [horizontal] 40 | `NNG_ENOMEM`:: Insufficient memory is available. 41 | `NNG_ENOTSUP`:: The transport is not supported. 42 | 43 | == SEE ALSO 44 | 45 | [.text-left] 46 | xref:nng_zerotier.7.adoc[nng_zerotier(7)], 47 | xref:nng.7.adoc[nng(7)] 48 | -------------------------------------------------------------------------------- /etc/codecov.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 Garrett D'Amore 4 | # Copyright 2017 Capitar IT Group BV 5 | # 6 | # This software is supplied under the terms of the MIT License, a 7 | # copy of which should be located in the distribution where this 8 | # file was obtained (LICENSE.txt). A copy of the license may also be 9 | # found online at https://opensource.org/licenses/MIT. 10 | 11 | if [ "${COVERAGE}" != ON ] 12 | then 13 | echo "Code coverage not enabled." 14 | exit 0 15 | fi 16 | 17 | GCOV=${GCOV:-gcov} 18 | 19 | bash <(curl -s https://codecov.io/bash) -x gcov || echo "Codecov did not collect coverage" 20 | echo 0 21 | -------------------------------------------------------------------------------- /etc/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017 Garrett D'Amore 4 | # Copyright 2017 Capitar IT Group BV 5 | # 6 | # This software is supplied under the terms of the MIT License, a 7 | # copy of which should be located in the distribution where this 8 | # file was obtained (LICENSE.txt). A copy of the license may also be 9 | # found online at https://opensource.org/licenses/MIT. 10 | 11 | if [ "${COVERAGE}" != ON ] 12 | then 13 | echo "Code coverage not enabled." 14 | exit 0 15 | fi 16 | 17 | GCOV=${GCOV:-gcov} 18 | 19 | # capture all coverage info 20 | lcov --gcov-tool ${GCOV} --directory . --capture --output-file coverage.info || exit 1 21 | 22 | # filter out system information (C++ templates & inlines) 23 | lcov --remove coverage.info '/usr/*' --output-file coverage.info || exit 1 24 | 25 | # filter out the *test* program data 26 | lcov --remove coverage.info '*/tests/*' --output-file coverage.info || exit 1 27 | 28 | # emit debug stats. 29 | lcov --list coverage.info 30 | 31 | rm coverage.info 32 | 33 | echo 0 34 | -------------------------------------------------------------------------------- /etc/nng.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": ".." 6 | } 7 | ], 8 | "settings": 9 | { 10 | "tab_size": 8, 11 | "translate_tabs_to_spaces": false, 12 | "ClangFormat": { 13 | "style": "File", 14 | "format_on_save": true 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /etc/pubrefman/README.adoc: -------------------------------------------------------------------------------- 1 | = pubrefman 2 | 3 | This directory contains a tool to publish (update) the reference manual 4 | on the NNG documentation site. 5 | 6 | Run it with --help for options. You can build it with Go. 7 | 8 | It normally uploads to github, and will require a working SSH agent. 9 | 10 | If you're not a project maintainer, you probably don't need this tool. 11 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/bus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_BUS_H 12 | #define NNG_COMPAT_BUS_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // BUS sockopt level. 24 | #define NN_PROTO_BUS 7 25 | #define NN_BUS (NN_PROTO_BUS * 16 + 0) 26 | 27 | // BUS has no options. 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // NNG_COMPAT_BUS_H 34 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/inproc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_INPROC_H 12 | #define NNG_COMPAT_INPROC_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // inproc sockopt level. 24 | // There are no inproc tunables. 25 | #define NN_INPROC (-1) 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif // NNG_COMPAT_INPROC_H 32 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/ipc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_IPC_H 12 | #define NNG_COMPAT_IPC_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // IPC sockopt level. 24 | #define NN_IPC (-2) 25 | 26 | // IPC options. Note that these are not currently supported. 27 | // IPC_SEC_ATTR works quite differently in NNG, and must be 28 | // configured using the new API. The buffer sizing options are 29 | // not supported at all. None of these were ever documented, and 30 | // are offered here only for source compatibility. 31 | #define NN_IPC_SEC_ATTR 1 32 | #define NN_IPC_OUTBUFSZ 2 33 | #define NN_IPC_INBUFSZ 3 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // NNG_COMPAT_IPC_H 40 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/pair.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_PAIR_H 12 | #define NNG_COMPAT_PAIR_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // PAIR sockopt level. 24 | #define NN_PROTO_PAIR 1 25 | #define NN_PAIR (NN_PROTO_PAIR * 16 + 0) 26 | 27 | // These are technically "new", and not available in nanomsg, but 28 | // offered here as a transition aid. If you want to use the advanced 29 | // PAIRv1 options (POLYAMOROUS mode) you still need to use the new API. 30 | #define NN_PAIR_v0 (NN_PROTO_PAIR * 16 + 0) 31 | #define NN_PAIR_V1 (NN_PROTO_PAIR * 16 + 1) 32 | 33 | // PAIR has no options. 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // NNG_COMPAT_PAIR_H 40 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/pipeline.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_PIPELINE_H 12 | #define NNG_COMPAT_PIPELINE_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // PUSH and PULL sockopt level. 24 | #define NN_PROTO_PIPELINE 5 25 | #define NN_PUSH (NN_PROTO_PIPELINE * 16 + 0) 26 | #define NN_PULL (NN_PROTO_PIPELINE * 16 + 1) 27 | 28 | // PUSH and PULL have no options. 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // NNG_COMPAT_PIPELINE_H 35 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/pubsub.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_PUBSUB_H 12 | #define NNG_COMPAT_PUBSUB_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // PUB and SUB sockopt level. 24 | #define NN_PROTO_PUBSUB 2 25 | #define NN_PUB (NN_PROTO_PUBSUB * 16 + 0) 26 | #define NN_SUB (NN_PROTO_PUBSUB * 16 + 1) 27 | 28 | // SUB options. (PUB has none.) 29 | #define NN_SUB_SUBSCRIBE (NN_SUB * 16 + 1) 30 | #define NN_SUB_UNSUBSCRIBE (NN_SUB * 16 + 2) 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif // NNG_COMPAT_PUBSUB_H 37 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/reqrep.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_REQREP_H 12 | #define NNG_COMPAT_REQREP_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // REQ and REP sockopt level. 24 | #define NN_PROTO_REQREP 3 25 | #define NN_REQ (NN_PROTO_REQREP * 16 + 0) 26 | #define NN_REP (NN_PROTO_REQREP * 16 + 1) 27 | 28 | // REQ options. (REP has none.) 29 | #define NN_REQ_RESEND_IVL (NN_REQ * 16 + 1) 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // NNG_COMPAT_REQREP_H 36 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/survey.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_SURVEY_H 12 | #define NNG_COMPAT_SURVEY_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // SURVEYOR and RESPONDENT sockopt level. 24 | #define NN_PROTO_SURVEY 6 25 | #define NN_SURVEYOR (NN_PROTO_SURVEY * 16 + 2) 26 | #define NN_RESPONDENT (NN_PROTO_SURVEY * 16 + 3) 27 | 28 | // SURVEYOR options. (RESPONDENT has none.) 29 | 30 | #define NN_SURVEYOR_DEADLINE (NN_SURVEYOR * 16 + 1) 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif // NNG_COMPAT_SURVEY_H 37 | -------------------------------------------------------------------------------- /include/nng/compat/nanomsg/tcp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_COMPAT_TCP_H 12 | #define NNG_COMPAT_TCP_H 13 | 14 | // This header contains interfaces that are intended to offer compatibility 15 | // with nanomsg v1.0. These are not the "preferred" interfaces for nng, 16 | // and consumers should only use these if they are porting software that 17 | // previously used nanomsg. New programs should use the nng native APIs. 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // TCP sockopt level. 24 | #define NN_TCP (-3) 25 | 26 | // TCP options. 27 | #define NN_TCP_NODELAY 1 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // NNG_COMPAT_TCP_H 34 | -------------------------------------------------------------------------------- /include/nng/mqtt/transport/tcp/mqtt_tcp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2017 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_MQTT_TCP_TCP_H 12 | #define NNG_TRANSPORT_MQTT_TCP_TCP_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // TCP transport. This is used for communication over TCP/IP. 21 | 22 | #ifndef NNG_ELIDE_DEPRECATED 23 | NNG_DECL int nng_mqtt_tcp_register(void); 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // NNG_TRANSPORT_MQTT_TCP_TCP_H 31 | -------------------------------------------------------------------------------- /include/nng/mqtt/transport/tls/mqtt_tls.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2017 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_MQTT_TLS_TLS_H 12 | #define NNG_TRANSPORT_MQTT_TLS_TLS_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // TCP transport. This is used for communication over TCP/IP. 21 | 22 | #ifndef NNG_ELIDE_DEPRECATED 23 | NNG_DECL int nng_mqtts_tcp_register(void); 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // NNG_TRANSPORT_MQTT_TLS_TLS_H 31 | -------------------------------------------------------------------------------- /include/nng/protocol/bus0/bus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_BUS0_BUS_H 12 | #define NNG_PROTOCOL_BUS0_BUS_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_bus0_open(nng_socket *); 19 | 20 | NNG_DECL int nng_bus0_open_raw(nng_socket *); 21 | 22 | #ifndef nng_bus_open 23 | #define nng_bus_open nng_bus0_open 24 | #endif 25 | 26 | #ifndef nng_bus_open_raw 27 | #define nng_bus_open_raw nng_bus0_open_raw 28 | #endif 29 | 30 | #define NNG_BUS0_SELF 0x70 31 | #define NNG_BUS0_PEER 0x70 32 | #define NNG_BUS0_SELF_NAME "bus" 33 | #define NNG_BUS0_PEER_NAME "bus" 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // NNG_PROTOCOL_BUS0_BUS_H 40 | -------------------------------------------------------------------------------- /include/nng/protocol/pair0/pair.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_PAIR0_PAIR_H 12 | #define NNG_PROTOCOL_PAIR0_PAIR_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_pair0_open(nng_socket *); 19 | 20 | NNG_DECL int nng_pair0_open_raw(nng_socket *); 21 | 22 | #ifndef nng_pair_open 23 | #define nng_pair_open nng_pair0_open 24 | #endif 25 | 26 | #ifndef nng_pair_open_raw 27 | #define nng_pair_open_raw nng_pair0_open_raw 28 | #endif 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // NNG_PROTOCOL_PAIR0_PAIR_H 35 | -------------------------------------------------------------------------------- /include/nng/protocol/pair1/pair.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_PAIR1_PAIR_H 12 | #define NNG_PROTOCOL_PAIR1_PAIR_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_pair1_open(nng_socket *); 19 | NNG_DECL int nng_pair1_open_raw(nng_socket *); 20 | NNG_DECL int nng_pair1_open_poly(nng_socket *); 21 | 22 | #ifndef nng_pair_open 23 | #define nng_pair_open nng_pair1_open 24 | #endif 25 | 26 | #ifndef nng_pair_open_raw 27 | #define nng_pair_open_raw nng_pair1_open_raw 28 | #endif 29 | 30 | #define NNG_OPT_PAIR1_POLY "pair1:polyamorous" 31 | #define NNG_PAIR1_SELF 0x11 32 | #define NNG_PAIR1_PEER 0x11 33 | #define NNG_PAIR1_SELF_NAME "pair1" 34 | #define NNG_PAIR1_PEER_NAME "pair1" 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // NNG_PROTOCOL_PAIR1_PAIR_H 41 | -------------------------------------------------------------------------------- /include/nng/protocol/pipeline0/pull.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_PIPELINE0_PULL_H 12 | #define NNG_PROTOCOL_PIPELINE0_PULL_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_pull0_open(nng_socket *); 19 | NNG_DECL int nng_pull0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_pull_open 22 | #define nng_pull_open nng_pull0_open 23 | #endif 24 | 25 | #ifndef nng_pull_open_raw 26 | #define nng_pull_open_raw nng_pull0_open_raw 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // NNG_PROTOCOL_PIPELINE0_PULL_H 34 | -------------------------------------------------------------------------------- /include/nng/protocol/pipeline0/push.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_PIPELINE0_PUSH_H 12 | #define NNG_PROTOCOL_PIPELINE0_PUSH_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_push0_open(nng_socket *); 19 | NNG_DECL int nng_push0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_push_open 22 | #define nng_push_open nng_push0_open 23 | #endif 24 | 25 | #ifndef nng_push_open_raw 26 | #define nng_push_open_raw nng_push0_open_raw 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // NNG_PROTOCOL_PIPELINE0_PUSH_H 34 | -------------------------------------------------------------------------------- /include/nng/protocol/pubsub0/pub.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_PUBSUB0_PUB_H 12 | #define NNG_PROTOCOL_PUBSUB0_PUB_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_pub0_open(nng_socket *); 19 | NNG_DECL int nng_pub0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_pub_open 22 | #define nng_pub_open nng_pub0_open 23 | #endif 24 | 25 | #ifndef nng_pub_open_raw 26 | #define nng_pub_open_raw nng_pub0_open_raw 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // NNG_PROTOCOL_PUBSUB0_PUB_H 34 | -------------------------------------------------------------------------------- /include/nng/protocol/pubsub0/sub.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_PUBSUB0_SUB_H 12 | #define NNG_PROTOCOL_PUBSUB0_SUB_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_sub0_open(nng_socket *); 19 | 20 | NNG_DECL int nng_sub0_open_raw(nng_socket *); 21 | 22 | #ifndef nng_sub_open 23 | #define nng_sub_open nng_sub0_open 24 | #endif 25 | 26 | #ifndef nng_sub_open_raw 27 | #define nng_sub_open_raw nng_sub0_open_raw 28 | #endif 29 | 30 | #define NNG_OPT_SUB_SUBSCRIBE "sub:subscribe" 31 | #define NNG_OPT_SUB_UNSUBSCRIBE "sub:unsubscribe" 32 | 33 | #define NNG_OPT_SUB_PREFNEW "sub:prefnew" 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // NNG_PROTOCOL_PUBSUB0_SUB_H 40 | -------------------------------------------------------------------------------- /include/nng/protocol/reqrep0/rep.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_REQREP0_REP_H 12 | #define NNG_PROTOCOL_REQREP0_REP_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_rep0_open(nng_socket *); 19 | NNG_DECL int nng_rep0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_rep_open 22 | #define nng_rep_open nng_rep0_open 23 | #endif 24 | 25 | #ifndef nng_rep_open_raw 26 | #define nng_rep_open_raw nng_rep0_open_raw 27 | #endif 28 | 29 | #define NNG_REP0_SELF 0x31 30 | #define NNG_REP0_PEER 0x30 31 | #define NNG_REP0_SELF_NAME "rep" 32 | #define NNG_REP0_PEER_NAME "req" 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif // NNG_PROTOCOL_REQREP0_REP_H 39 | -------------------------------------------------------------------------------- /include/nng/protocol/reqrep0/req.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_REQREP0_REQ_H 12 | #define NNG_PROTOCOL_REQREP0_REQ_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_req0_open(nng_socket *); 19 | NNG_DECL int nng_req0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_req_open 22 | #define nng_req_open nng_req0_open 23 | #endif 24 | #ifndef nng_req_open_raw 25 | #define nng_req_open_raw nng_req0_open_raw 26 | #endif 27 | 28 | #define NNG_REQ0_SELF 0x30 29 | #define NNG_REQ0_PEER 0x31 30 | #define NNG_REQ0_SELF_NAME "req" 31 | #define NNG_REQ0_PEER_NAME "rep" 32 | 33 | #define NNG_OPT_REQ_RESENDTIME "req:resend-time" 34 | #define NNG_OPT_REQ_RESENDTICK "req:resend-tick" 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // NNG_PROTOCOL_REQREP0_REQ_H 41 | -------------------------------------------------------------------------------- /include/nng/protocol/survey0/respond.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_SURVEY0_RESPOND_H 12 | #define NNG_PROTOCOL_SURVEY0_RESPOND_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_respondent0_open(nng_socket *); 19 | NNG_DECL int nng_respondent0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_respondent_open 22 | #define nng_respondent_open nng_respondent0_open 23 | #endif 24 | 25 | #ifndef nng_respondent_open_raw 26 | #define nng_respondent_open_raw nng_respondent0_open_raw 27 | #endif 28 | 29 | #define NNG_RESPONDENT0_SELF 0x63 30 | #define NNG_RESPONDENT0_PEER 0x62 31 | #define NNG_RESPONDENT0_SELF_NAME "respondent" 32 | #define NNG_RESPONDENT0_PEER_NAME "surveyor" 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif // NNG_PROTOCOL_SURVEY0_RESPOND_H 39 | -------------------------------------------------------------------------------- /include/nng/protocol/survey0/survey.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_PROTOCOL_SURVEY0_SURVEY_H 12 | #define NNG_PROTOCOL_SURVEY0_SURVEY_H 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | NNG_DECL int nng_surveyor0_open(nng_socket *); 19 | NNG_DECL int nng_surveyor0_open_raw(nng_socket *); 20 | 21 | #ifndef nng_surveyor_open 22 | #define nng_surveyor_open nng_surveyor0_open 23 | #endif 24 | 25 | #ifndef nng_surveyor_open_raw 26 | #define nng_surveyor_open_raw nng_surveyor0_open_raw 27 | #endif 28 | 29 | #define NNG_SURVEYOR0_SELF 0x62 30 | #define NNG_SURVEYOR0_PEER 0x63 31 | #define NNG_SURVEYOR0_SELF_NAME "surveyor" 32 | #define NNG_SURVEYOR0_PEER_NAME "respondent" 33 | 34 | #define NNG_OPT_SURVEYOR_SURVEYTIME "surveyor:survey-time" 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // NNG_PROTOCOL_SURVEY0_SURVEY_H 41 | -------------------------------------------------------------------------------- /include/nng/supplemental/nanolib/base64.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE64_H 2 | #define BASE64_H 3 | #include "nng/nng.h" 4 | 5 | #define BASE64_ENCODE_OUT_SIZE(s) ((unsigned int)((((s) + 2) / 3) * 4 + 1)) 6 | #define BASE64_DECODE_OUT_SIZE(s) ((unsigned int)(((s) / 4) * 3)) 7 | 8 | /* 9 | * out is null-terminated encode string. 10 | * return values is out length, exclusive terminating `\0' 11 | */ 12 | NNG_DECL unsigned int 13 | base64_encode(const unsigned char *in, unsigned int inlen, char *out); 14 | 15 | /* 16 | * return values is out length 17 | */ 18 | NNG_DECL unsigned int 19 | base64_decode(const char *in, unsigned int inlen, unsigned char *out); 20 | 21 | #endif /* BASE64_H */ -------------------------------------------------------------------------------- /include/nng/supplemental/nanolib/file.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2023 NanoMQ Team, Inc. // 3 | // This software is supplied under the terms of the MIT License, a 4 | // copy of which should be located in the distribution where this 5 | // file was obtained (LICENSE.txt). A copy of the license may also be 6 | // found online at https://opensource.org/licenses/MIT. 7 | // 8 | 9 | #ifndef NANO_FILE_H 10 | #define NANO_FILE_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include "nng/nng.h" 16 | 17 | NNG_DECL bool nano_file_exists(const char *fpath); 18 | NNG_DECL char * nano_getcwd(char *buf, size_t size); 19 | NNG_DECL int64_t nano_getline( 20 | char **restrict line, size_t *restrict len, FILE *restrict fp); 21 | NNG_DECL char * nano_concat_path(const char *dir, const char *file_name); 22 | NNG_DECL int file_write_string(const char *fpath, const char *string); 23 | NNG_DECL size_t file_load_data(const char *filepath, void **data); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/nng/supplemental/util/idhash.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef NNG_SUPPLEMENTAL_UTIL_IDHASH_H 11 | #define NNG_SUPPLEMENTAL_UTIL_IDHASH_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include 18 | 19 | typedef struct nng_id_map_s nng_id_map; 20 | 21 | #define NNG_MAP_RANDOM 1 22 | 23 | NNG_DECL int nng_id_map_alloc( 24 | nng_id_map **map, uint64_t lo, uint64_t hi, int flags); 25 | NNG_DECL void nng_id_map_free(nng_id_map *map); 26 | NNG_DECL void *nng_id_get(nng_id_map *, uint64_t); 27 | NNG_DECL int nng_id_set(nng_id_map *, uint64_t, void *); 28 | NNG_DECL int nng_id_alloc(nng_id_map *, uint64_t *, void *); 29 | NNG_DECL int nng_id_remove(nng_id_map *, uint64_t); 30 | NNG_DECL bool nng_id_visit(nng_id_map *, uint64_t *, void **, uint32_t *); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif // NNG_SUPPLEMENTAL_IDHASH_IDHASH_H 37 | -------------------------------------------------------------------------------- /include/nng/supplemental/util/platform.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef NNG_SUPPLEMENTAL_UTIL_PLATFORM_H 11 | #define NNG_SUPPLEMENTAL_UTIL_PLATFORM_H 12 | 13 | // The declarations in this file have been relocated to . 14 | // This file itself is deprecated, and applications should stop including 15 | // it directly. 16 | #include 17 | 18 | #endif // NNG_SUPPLEMENTAL_UTIL_PLATFORM_H 19 | -------------------------------------------------------------------------------- /include/nng/transport/inproc/inproc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2017 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_INPROC_INPROC_H 12 | #define NNG_TRANSPORT_INPROC_INPROC_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // inproc transport. This is used for intra-process communication. 21 | #ifndef NNG_ELIDE_DEPRECATED 22 | NNG_DECL int nng_inproc_register(void); 23 | #endif 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif // NNG_TRANSPORT_INPROC_INPROC_H 30 | -------------------------------------------------------------------------------- /include/nng/transport/ipc/ipc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_IPC_IPC_H 12 | #define NNG_TRANSPORT_IPC_IPC_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // ipc transport. This is used for inter-process communication on 21 | // the same host computer. 22 | 23 | #ifndef NNG_ELIDE_DEPRECATED 24 | NNG_DECL int nng_ipc_register(void); 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif // NNG_TRANSPORT_IPC_IPC_H 32 | -------------------------------------------------------------------------------- /include/nng/transport/tcp/tcp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2017 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_TCP_TCP_H 12 | #define NNG_TRANSPORT_TCP_TCP_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // TCP transport. This is used for communication over TCP/IP. 21 | 22 | #ifndef NNG_ELIDE_DEPRECATED 23 | NNG_DECL int nng_tcp_register(void); 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // NNG_TRANSPORT_TCP_TCP_H 31 | -------------------------------------------------------------------------------- /include/nng/transport/tls/tls.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2019 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_TLS_TLS_H 12 | #define NNG_TRANSPORT_TLS_TLS_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // TLS transport. This is used for communication via TLS v1.2 over TCP/IP. 21 | 22 | #ifndef NNG_ELIDE_DEPRECATED 23 | NNG_DECL int nng_tls_register(void); 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // NNG_TRANSPORT_TLS_TLS_H 31 | -------------------------------------------------------------------------------- /include/nng/transport/ws/websocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_TRANSPORT_WS_WEBSOCKET_H 12 | #define NNG_TRANSPORT_WS_WEBSOCKET_H 13 | 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | // WebSocket transport. This is used for communication via WebSocket. 21 | 22 | // These aliases are for WSS naming consistency. 23 | #define NNG_OPT_WSS_REQUEST_HEADERS NNG_OPT_WS_REQUEST_HEADERS 24 | #define NNG_OPT_WSS_RESPONSE_HEADERS NNG_OPT_WS_RESPONSE_HEADERS 25 | 26 | #ifndef NNG_ELIDE_DEPRECATED 27 | NNG_DECL int nng_ws_register(void); 28 | NNG_DECL int nng_wss_register(void); 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // NNG_TRANSPORT_WS_WEBSOCKET_H 36 | -------------------------------------------------------------------------------- /src/compat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_directory(compat) 11 | 12 | add_subdirectory(nanomsg) 13 | -------------------------------------------------------------------------------- /src/compat/nanomsg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_sources(nn.c) 11 | 12 | set(NNG_TEST_PREFIX ${NNG_TEST_PREFIX}.compat.nanomsg) 13 | 14 | nng_test(compat_msg_test) 15 | nng_test(compat_tcp_test) 16 | -------------------------------------------------------------------------------- /src/core/device.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef CORE_DEVICE_H 11 | #define CORE_DEVICE_H 12 | 13 | // Device takes messages from one side, and forwards them to the other. 14 | // It works in both directions. Arguably we should build versions of this 15 | // that are unidirectional, and we could extend this API with user-defined 16 | // filtering functions. 17 | extern void nni_device(nni_aio *aio, nni_sock *, nni_sock *); 18 | 19 | #endif // CORE_DEVICE_H 20 | -------------------------------------------------------------------------------- /src/core/dialer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // Copyright 2018 Devolutions 5 | // 6 | // This software is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | #ifndef CORE_DIALER_H 13 | #define CORE_DIALER_H 14 | 15 | extern int nni_dialer_find(nni_dialer **, uint32_t); 16 | extern int nni_dialer_hold(nni_dialer *); 17 | extern void nni_dialer_rele(nni_dialer *); 18 | extern uint32_t nni_dialer_id(nni_dialer *); 19 | extern int nni_dialer_create(nni_dialer **, nni_sock *, const char *); 20 | extern void nni_dialer_close(nni_dialer *); 21 | extern int nni_dialer_start(nni_dialer *, unsigned); 22 | extern nni_sock *nni_dialer_sock(nni_dialer *); 23 | 24 | extern int nni_dialer_setopt( 25 | nni_dialer *, const char *, const void *, size_t, nni_type); 26 | extern int nni_dialer_getopt( 27 | nni_dialer *, const char *, void *, size_t *, nni_type); 28 | extern void nni_dialer_add_stat(nni_dialer *, nni_stat_item *); 29 | extern void nni_dialer_bump_error(nni_dialer *, int); 30 | 31 | #endif // CORE_DIALER_H 32 | -------------------------------------------------------------------------------- /src/core/errors_test.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | static void 16 | test_known_errors(void) 17 | { 18 | NUTS_MATCH(nng_strerror(NNG_ECLOSED), "Object closed"); 19 | NUTS_MATCH(nng_strerror(NNG_ETIMEDOUT), "Timed out"); 20 | } 21 | 22 | static void 23 | test_unknown_errors(void) 24 | { 25 | for (unsigned i = 1; i < 0x1000000; i = i * 2 + 100) { 26 | NUTS_TRUE(nng_strerror(i) != NULL); 27 | } 28 | } 29 | 30 | static void 31 | test_system_errors(void) 32 | { 33 | NUTS_MATCH(nng_strerror(NNG_ESYSERR + ENOENT), strerror(ENOENT)); 34 | NUTS_MATCH(nng_strerror(NNG_ESYSERR + EINVAL), strerror(EINVAL)); 35 | } 36 | 37 | NUTS_TESTS = { 38 | { "known errors", test_known_errors }, 39 | { "unknown errors", test_unknown_errors }, 40 | { "system errors", test_system_errors }, 41 | { NULL, NULL }, 42 | }; 43 | -------------------------------------------------------------------------------- /src/core/listener.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // Copyright 2018 Devolutions 5 | // 6 | // This software is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | #ifndef CORE_LISTENER_H 13 | #define CORE_LISTENER_H 14 | 15 | extern int nni_listener_find(nni_listener **, uint32_t); 16 | extern int nni_listener_hold(nni_listener *); 17 | extern void nni_listener_rele(nni_listener *); 18 | extern uint32_t nni_listener_id(nni_listener *); 19 | extern int nni_listener_create(nni_listener **, nni_sock *, const char *); 20 | extern void nni_listener_close(nni_listener *); 21 | extern int nni_listener_start(nni_listener *, int); 22 | extern nni_sock *nni_listener_sock(nni_listener *); 23 | 24 | extern int nni_listener_setopt( 25 | nni_listener *, const char *, const void *, size_t, nni_type); 26 | extern int nni_listener_getopt( 27 | nni_listener *, const char *, void *, size_t *, nni_type); 28 | extern void nni_listener_add_stat(nni_listener *, nni_stat_item *); 29 | extern void nni_listener_bump_error(nni_listener *, int); 30 | 31 | #endif // CORE_LISTENER_H 32 | -------------------------------------------------------------------------------- /src/core/panic.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Garrett D'Amore 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef CORE_PANIC_H 11 | #define CORE_PANIC_H 12 | 13 | // nni_panic is used to terminate the process with prejudice, and 14 | // should only be called in the face of a critical programming error, 15 | // or other situation where it would be unsafe to attempt to continue. 16 | // As this crashes the program, it should never be used when factors outside 17 | // the program can cause it, such as receiving protocol errors, or running 18 | // out of memory. Its better in those cases to return an error to the 19 | // program and let the caller handle the error situation. 20 | extern void nni_panic(const char *, ...); 21 | 22 | // nni_println is used to print output to a debug console. This should only 23 | // be used in the most dire of circumstances -- such as during an assertion 24 | // failure that is going to cause the program to crash. After the string is 25 | // emitted, a new line character is emitted, so the string should not 26 | // include one. 27 | extern void nni_println(const char *); 28 | 29 | #endif // CORE_PANIC_H 30 | -------------------------------------------------------------------------------- /src/core/pollable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef CORE_POLLABLE_H 11 | #define CORE_POLLABLE_H 12 | 13 | #include "core/defs.h" 14 | #include "core/list.h" 15 | 16 | typedef struct nni_pollable nni_pollable; 17 | 18 | extern void nni_pollable_raise(nni_pollable *); 19 | extern void nni_pollable_clear(nni_pollable *); 20 | extern int nni_pollable_getfd(nni_pollable *, int *); 21 | 22 | // nni_pollable implementation details are private. Only here for inlining. 23 | // We have joined the write and read file descriptors into a single 24 | // atomic 64, so we can update them together (and we can use cas to be sure 25 | // that such updates are always safe.) 26 | struct nni_pollable { 27 | nni_atomic_u64 p_fds; 28 | nni_atomic_bool p_raised; 29 | }; 30 | 31 | extern void nni_pollable_init(nni_pollable *); 32 | extern void nni_pollable_fini(nni_pollable *); 33 | 34 | #endif // CORE_POLLABLE_H 35 | -------------------------------------------------------------------------------- /src/core/sockfd.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2023 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef CORE_FDC_H 11 | #define CORE_FDC_H 12 | 13 | #include "core/nng_impl.h" 14 | 15 | // the nni_sfd_conn struct is provided by platform code to wrap 16 | // an arbitrary byte stream file descriptor (UNIX) or handle (Windows) 17 | // with a nng_stream. 18 | typedef struct nni_sfd_conn nni_sfd_conn; 19 | extern int nni_sfd_conn_alloc(nni_sfd_conn **cp, int fd); 20 | extern int nni_sfd_dialer_alloc(nng_stream_dialer **, const nng_url *); 21 | extern int nni_sfd_listener_alloc(nng_stream_listener **, const nng_url *); 22 | 23 | // this is used to close a file descriptor, in case we cannot 24 | // create a connection (or if the listener is closed before the 25 | // connection is accepted.) 26 | extern void nni_sfd_close_fd(int fd); 27 | 28 | #endif // CORE_FDC_H 29 | -------------------------------------------------------------------------------- /src/core/strs.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2017 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef CORE_STRS_H 12 | #define CORE_STRS_H 13 | 14 | // Safe string functions, in case the platform misses these. 15 | 16 | extern char * nni_strdup(const char *); 17 | extern char * nni_strndup(const char *, size_t); 18 | extern void nni_strfree(char *); 19 | extern size_t nni_strlcpy(char *, const char *, size_t); 20 | extern size_t nni_strnlen(const char *, size_t); 21 | extern char * nni_strcasestr(const char *, const char *); 22 | extern int nni_strncasecmp(const char *, const char *, size_t); 23 | extern int nni_strcasecmp(const char *, const char *); 24 | extern int nni_asprintf(char **, const char *, ...); 25 | 26 | #endif // CORE_STRS_H 27 | -------------------------------------------------------------------------------- /src/core/tcp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef CORE_TCP_H 11 | #define CORE_TCP_H 12 | 13 | #include "core/nng_impl.h" 14 | 15 | // These are interfaces we use for TCP internally. These are not exposed 16 | // to the public API. 17 | 18 | extern int nni_tcp_dialer_alloc(nng_stream_dialer **, const nng_url *); 19 | extern int nni_tcp_listener_alloc(nng_stream_listener **, const nng_url *); 20 | 21 | #endif // CORE_TCP_H 22 | -------------------------------------------------------------------------------- /src/core/url.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef CORE_URL_H 12 | #define CORE_URL_H 13 | 14 | #include "core/defs.h" 15 | 16 | extern int nni_url_parse(nni_url **, const char *path); 17 | extern void nni_url_free(nni_url *); 18 | extern int nni_url_clone(nni_url **, const nni_url *); 19 | extern const char *nni_url_default_port(const char *); 20 | extern int nni_url_asprintf(char **, const nni_url *); 21 | extern int nni_url_asprintf_port(char **, const nni_url *, int); 22 | extern size_t nni_url_decode(uint8_t *, const char *, size_t); 23 | 24 | #endif // CORE_URL_H 25 | -------------------------------------------------------------------------------- /src/mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_directory(mqtt) 11 | 12 | add_subdirectory(protocol) 13 | add_subdirectory(transport) 14 | 15 | nng_sources( 16 | transport.c 17 | transport.h 18 | ) 19 | -------------------------------------------------------------------------------- /src/mqtt/protocol/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Protocols. 11 | nng_directory(protocol) 12 | 13 | add_subdirectory(mqtt) 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/mqtt/protocol/mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | # 7 | 8 | # MQTT protocol 9 | nng_directory(mqtt) 10 | 11 | nng_sources_if( 12 | NNG_PROTO_MQTT_CLIENT 13 | mqtt_client.c 14 | #mqttv5_client.c 15 | sqlite_handler.c 16 | sqlite_handler.h 17 | ) 18 | nng_headers_if(NNG_PROTO_MQTT_CLIENT nng/mqtt/mqtt_client.h) 19 | nng_defines_if(NNG_PROTO_MQTT_CLIENT NNG_HAVE_MQTT_CLIENT) 20 | 21 | nng_sources_if(NNG_PROTO_MQTT_QUIC_CLIENT mqtt_quic.c mqttv5_quic.c) 22 | nng_headers_if(NNG_PROTO_MQTT_QUIC_CLIENT nng/mqtt/mqtt_quic.h) 23 | nng_defines_if(NNG_PROTO_MQTT_QUIC_CLIENT NNG_HAVE_MQTT_QUIC_CLIENT) 24 | -------------------------------------------------------------------------------- /src/mqtt/protocol/mqtt/sqlite_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef SQLITE_HANDLER_H 2 | #define SQLITE_HANDLER_H 3 | 4 | #include "core/nng_impl.h" 5 | #include "nng/nng.h" 6 | #include "supplemental/mqtt/mqtt_qos_db.h" 7 | 8 | extern bool sqlite_is_enabled(nni_mqtt_sqlite_option *); 9 | extern nni_msg *sqlite_get_cache_msg(nni_mqtt_sqlite_option *); 10 | extern void sqlite_flush_lmq(nni_mqtt_sqlite_option *, nni_lmq *); 11 | extern void sqlite_flush_offline_cache(nni_mqtt_sqlite_option *); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/mqtt/transport.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // Copyright 2018 Devolutions 5 | // 6 | // This software is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | #ifndef PROTOCOL_MQTT_TRANSPORT_H 13 | #define PROTOCOL_MQTT_TRANSPORT_H 14 | 15 | #include "core/options.h" 16 | 17 | // These APIs are used by the framework internally, and not for use by 18 | // transport implementations. 19 | extern nni_sp_tran *nni_mqtt_tran_find(nni_url *); 20 | extern void nni_mqtt_tran_sys_init(void); 21 | extern void nni_mqtt_tran_sys_fini(void); 22 | extern void nni_mqtt_tran_register(nni_sp_tran *); 23 | 24 | #endif // PROTOCOL_MQTT_TRANSPORT_H 25 | -------------------------------------------------------------------------------- /src/mqtt/transport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Transports. 11 | nng_directory(transport) 12 | 13 | add_subdirectory(tcp) 14 | add_subdirectory(tls) 15 | 16 | -------------------------------------------------------------------------------- /src/mqtt/transport/tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # TCP protocol 12 | nng_directory(mqtt) 13 | 14 | nng_sources_if(NNG_TRANSPORT_MQTT_TCP mqtt_tcp.c) 15 | nng_headers_if(NNG_TRANSPORT_MQTT_TCP nng/mqtt/transport/tcp/mqtt_tcp.h) 16 | nng_defines_if(NNG_TRANSPORT_MQTT_TCP NNG_TRANSPORT_MQTT_TCP) 17 | -------------------------------------------------------------------------------- /src/mqtt/transport/tls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # TCP protocol 12 | nng_directory(mqtts) 13 | 14 | nng_sources_if(NNG_TRANSPORT_MQTT_TLS mqtt_tls.c) 15 | nng_headers_if(NNG_TRANSPORT_MQTT_TLS nng/mqtt/transport/tls/mqtt_tls.h) 16 | nng_defines_if(NNG_TRANSPORT_MQTT_TLS NNG_TRANSPORT_MQTT_TLS) 17 | -------------------------------------------------------------------------------- /src/platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Platforms. 11 | nng_directory(platform) 12 | 13 | add_subdirectory(posix) 14 | add_subdirectory(windows) 15 | 16 | nng_test(platform_test) 17 | nng_test(resolver_test) 18 | nng_test(udp_test) 19 | -------------------------------------------------------------------------------- /src/platform/posix/posix_alloc.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Garrett D'Amore 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #include "core/nng_impl.h" 11 | 12 | #ifdef NNG_PLATFORM_POSIX 13 | 14 | #include 15 | 16 | // POSIX memory allocation. This is pretty much standard C. 17 | void * 18 | nni_alloc(size_t sz) 19 | { 20 | return (sz > 0 ? malloc(sz) : NULL); 21 | } 22 | 23 | void * 24 | nni_zalloc(size_t sz) 25 | { 26 | return (sz > 0 ? calloc(1, sz) : NULL); 27 | } 28 | 29 | void 30 | nni_free(void *ptr, size_t size) 31 | { 32 | NNI_ARG_UNUSED(size); 33 | free(ptr); 34 | } 35 | 36 | #endif // NNG_PLATFORM_POSIX 37 | -------------------------------------------------------------------------------- /src/platform/posix/posix_ipcwinsec_test.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | #include 11 | #include 12 | 13 | void 14 | test_ipc_win_sec(void) 15 | { 16 | char address[64]; 17 | nng_stream_listener *l; 18 | int x; 19 | 20 | nuts_scratch_addr("ipc", sizeof(address), address); 21 | NUTS_PASS(nng_stream_listener_alloc(&l, address)); 22 | NUTS_FAIL(nng_stream_listener_set_ptr( 23 | l, NNG_OPT_IPC_SECURITY_DESCRIPTOR, &x), 24 | NNG_ENOTSUP); 25 | nng_stream_listener_free(l); 26 | } 27 | 28 | NUTS_TESTS = { 29 | { "ipc security descriptor", test_ipc_win_sec }, 30 | { NULL, NULL }, 31 | }; 32 | -------------------------------------------------------------------------------- /src/platform/posix/posix_peerid.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2023 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef PLATFORM_POSIX_PEERID_H 11 | #define PLATFORM_POSIX_PEERID_H 12 | 13 | // This file defines structures we will use for emulating asynchronous I/O 14 | // on POSIX. POSIX lacks the support for callback based asynchronous I/O 15 | // that we have on Windows, although it has a non-widely support aio layer 16 | // that is not very performant on many systems. So we emulate this using 17 | // one of several possible different backends. 18 | 19 | #include "core/nng_impl.h" 20 | #include 21 | 22 | int nni_posix_peerid( 23 | int fd, uint64_t *euid, uint64_t *egid, uint64_t *prid, uint64_t *znid); 24 | 25 | #endif // PLATFORM_POSIX_PEERID_H -------------------------------------------------------------------------------- /src/platform/posix/posix_rand_arc4random.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | // arc4random is the preferred source of cryptographic random numbers 11 | // on any platform where it is found. 12 | #include 13 | 14 | #include "core/nng_impl.h" 15 | 16 | #ifdef NNG_HAVE_ARC4RANDOM 17 | 18 | uint32_t 19 | nni_random(void) 20 | { 21 | return (arc4random()); 22 | } 23 | 24 | #endif -------------------------------------------------------------------------------- /src/platform/posix/posix_socketpair.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2023 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #include "core/nng_impl.h" 11 | 12 | #ifdef NNG_HAVE_SOCKETPAIR 13 | // This provides an implementation of socketpair(), which is supposed 14 | // to be present on XPG6 and newer. This trivial implementation 15 | // only supports SOCK_STREAM over AF_UNIX. Which is sufficient for 16 | // most purposes. The fds array should point to an int[2]. 17 | #include 18 | #include 19 | 20 | int 21 | nni_socket_pair(int fds[2]) 22 | { 23 | int rv; 24 | rv = socketpair(PF_UNIX, SOCK_STREAM, 0, fds); 25 | if (rv != 0) { 26 | return (nni_plat_errno(errno)); 27 | } 28 | 29 | #ifdef SO_NOSIGPIPE 30 | int set = 1; 31 | setsockopt(fds[0], SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)); 32 | setsockopt(fds[1], SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)); 33 | #endif 34 | 35 | return (0); 36 | } 37 | #else 38 | int 39 | nni_socket_pair(int fds[2]) 40 | { 41 | return (NNG_ENOTSUP); 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /src/platform/windows/win_ipc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2019 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // Copyright 2019 Devolutions 5 | // 6 | // This software is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | #ifndef PLATFORM_WIN_WINIPC_H 13 | #define PLATFORM_WIN_WINIPC_H 14 | 15 | // This header file is private to the IPC (named pipes) support for Windows. 16 | 17 | #include "core/nng_impl.h" 18 | #include "win_impl.h" 19 | 20 | #define IPC_PIPE_PREFIX "\\\\.\\pipe\\" 21 | 22 | extern int nni_win_ipc_init(nng_stream **, HANDLE, const nng_sockaddr *, bool); 23 | 24 | #endif // NNG_PLATFORM_WIN_WINIPC_H 25 | -------------------------------------------------------------------------------- /src/platform/windows/win_rand.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #include "core/nng_impl.h" 11 | 12 | #ifdef NNG_PLATFORM_WINDOWS 13 | 14 | #ifndef _CRT_RAND_S 15 | #define _CRT_RAND_S 16 | #endif 17 | 18 | #include 19 | 20 | uint32_t 21 | nni_random(void) 22 | { 23 | unsigned val; 24 | 25 | // rand_s is claimed by Microsoft to generate cryptographically 26 | // secure numbers. It also is claimed that this will only fail 27 | // for EINVAL if val is NULL (not the case here). Other error 28 | // conditions might be possible, but we have no way to tell. 29 | // For now we just ignore that possibility. 30 | rand_s(&val); 31 | return ((uint32_t)val); 32 | } 33 | 34 | #endif // NNG_PLATFORM_WINDOWS -------------------------------------------------------------------------------- /src/platform/windows/win_socketpair.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2023 Staysail Systems, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #include "core/nng_impl.h" 11 | 12 | 13 | #ifdef NNG_HAVE_SOCKETPAIR_TODO 14 | // TODO: Windows lacks socketpair. We can emulate it with an explcit 15 | // implementation based on AF_UNIX. 16 | 17 | #include 18 | #include 19 | 20 | int 21 | nni_socket_pair(int fds[2]) 22 | { 23 | int rv; 24 | rv = socketpair(PF_UNIX, SOCK_STREAM, 0, fds); 25 | if (rv != 0) { 26 | return (nni_plat_errno(errno)); 27 | } 28 | 29 | return (0); 30 | } 31 | #else 32 | int 33 | nni_socket_pair(int fds[2]) 34 | { 35 | NNI_ARG_UNUSED(fds); 36 | return (NNG_ENOTSUP); 37 | } 38 | 39 | // This is also the fdc transport. 40 | 41 | typedef struct nni_sfd_conn nni_sfd_conn; 42 | 43 | void 44 | nni_sfd_close_fd(int fd) 45 | { 46 | NNI_ARG_UNUSED(fd); 47 | } 48 | 49 | int 50 | nni_sfd_conn_alloc(nni_sfd_conn **cp, int fd) 51 | { 52 | NNI_ARG_UNUSED(cp); 53 | NNI_ARG_UNUSED(fd); 54 | return (NNG_ENOTSUP); 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/platform/windows/win_tcp.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #include "core/nng_impl.h" 12 | 13 | #ifdef NNG_PLATFORM_WINDOWS 14 | 15 | #include 16 | #include 17 | 18 | int 19 | nni_win_tcp_sysinit(void) 20 | { 21 | WSADATA data; 22 | if (WSAStartup(MAKEWORD(2, 2), &data) != 0) { 23 | NNI_ASSERT(LOBYTE(data.wVersion) == 2); 24 | NNI_ASSERT(HIBYTE(data.wVersion) == 2); 25 | return (nni_win_error(GetLastError())); 26 | } 27 | return (0); 28 | } 29 | 30 | void 31 | nni_win_tcp_sysfini(void) 32 | { 33 | WSACleanup(); 34 | } 35 | 36 | #endif // NNG_PLATFORM_WINDOWS 37 | -------------------------------------------------------------------------------- /src/sp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_directory(sp) 11 | 12 | add_subdirectory(protocol) 13 | add_subdirectory(transport) 14 | 15 | nng_sources( 16 | protocol.c 17 | transport.c 18 | transport.h 19 | ) 20 | -------------------------------------------------------------------------------- /src/sp/protocol.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #include 12 | 13 | #include "core/nng_impl.h" 14 | 15 | int 16 | nni_proto_open(nng_socket *sip, const nni_proto *proto) 17 | { 18 | int rv; 19 | nni_sock *sock; 20 | 21 | if ((rv = nni_sock_open(&sock, proto)) == 0) { 22 | nng_socket s; 23 | s.id = nni_sock_id(sock); // Keep socket held open. 24 | *sip = s; 25 | } 26 | return (rv); 27 | } 28 | -------------------------------------------------------------------------------- /src/sp/protocol/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Protocols. 11 | nng_directory(protocol) 12 | 13 | add_subdirectory(bus0) 14 | add_subdirectory(pair0) 15 | add_subdirectory(pair1) 16 | add_subdirectory(pipeline0) 17 | add_subdirectory(pubsub0) 18 | add_subdirectory(reqrep0) 19 | add_subdirectory(survey0) 20 | 21 | -------------------------------------------------------------------------------- /src/sp/protocol/bus0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # Bus protocol 12 | nng_directory(bus0) 13 | 14 | nng_sources_if(NNG_PROTO_BUS0 bus.c) 15 | nng_headers_if(NNG_PROTO_BUS0 nng/protocol/bus0/bus.h) 16 | nng_defines_if(NNG_PROTO_BUS0 NNG_HAVE_BUS0) 17 | 18 | nng_test(bus_test) -------------------------------------------------------------------------------- /src/sp/protocol/pair0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # PAIRv0 protocol 12 | nng_directory(pair0) 13 | 14 | nng_sources_if(NNG_PROTO_PAIR0 pair.c) 15 | nng_headers_if(NNG_PROTO_PAIR0 nng/protocol/pair0/pair.h) 16 | nng_defines_if(NNG_PROTO_PAIR0 NNG_HAVE_PAIR0) 17 | nng_test(pair0_test) 18 | -------------------------------------------------------------------------------- /src/sp/protocol/pair1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # PAIRv1 protocol 12 | nng_directory(pair1) 13 | 14 | # XXX: break pair1_poly into an ifdef. 15 | nng_sources_if(NNG_PROTO_PAIR1 pair.c pair1_poly.c) 16 | nng_headers_if(NNG_PROTO_PAIR1 nng/protocol/pair1/pair.h) 17 | nng_defines_if(NNG_PROTO_PAIR1 NNG_HAVE_PAIR1) 18 | 19 | nng_test(pair1_test) 20 | nng_test(pair1_poly_test) -------------------------------------------------------------------------------- /src/sp/protocol/pipeline0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # Pipeline protocol 12 | nng_directory(pipeline0) 13 | 14 | nng_sources_if(NNG_PROTO_PUSH0 push.c) 15 | nng_headers_if(NNG_PROTO_PUSH0 nng/protocol/pipeline0/push.h) 16 | nng_defines_if(NNG_PROTO_PUSH0 NNG_HAVE_PUSH0) 17 | 18 | nng_sources_if(NNG_PROTO_PULL0 pull.c) 19 | nng_headers_if(NNG_PROTO_PULL0 nng/protocol/pipeline0/pull.h) 20 | nng_defines_if(NNG_PROTO_PULL0 NNG_HAVE_PULL0) 21 | 22 | nng_test(pull_test) 23 | nng_test(push_test) 24 | -------------------------------------------------------------------------------- /src/sp/protocol/pubsub0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # Pub/Sub protocol 12 | nng_directory(pubsub0) 13 | 14 | nng_sources_if(NNG_PROTO_PUB0 pub.c) 15 | nng_headers_if(NNG_PROTO_PUB0 nng/protocol/pubsub0/pub.h) 16 | nng_defines_if(NNG_PROTO_PUB0 NNG_HAVE_PUB0) 17 | 18 | nng_sources_if(NNG_PROTO_SUB0 sub.c xsub.c) 19 | nng_headers_if(NNG_PROTO_SUB0 nng/protocol/pubsub0/sub.h) 20 | nng_defines_if(NNG_PROTO_SUB0 NNG_HAVE_SUB0) 21 | 22 | nng_test(pub_test) 23 | nng_test(sub_test) 24 | nng_test(xsub_test) 25 | -------------------------------------------------------------------------------- /src/sp/protocol/reqrep0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # Req/Rep protocol 12 | nng_directory(reqrep0) 13 | 14 | nng_sources_if(NNG_PROTO_REQ0 req.c xreq.c) 15 | nng_headers_if(NNG_PROTO_REQ0 nng/protocol/reqrep0/req.h) 16 | nng_defines_if(NNG_PROTO_REQ0 NNG_HAVE_REQ0) 17 | 18 | nng_sources_if(NNG_PROTO_REP0 rep.c xrep.c) 19 | nng_headers_if(NNG_PROTO_REP0 nng/protocol/reqrep0/rep.h) 20 | nng_defines_if(NNG_PROTO_REP0 NNG_HAVE_REP0) 21 | 22 | nng_test(req_test) 23 | nng_test(rep_test) 24 | nng_test(xrep_test) 25 | nng_test(xreq_test) 26 | -------------------------------------------------------------------------------- /src/sp/protocol/survey0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # Surveyor/Respondent protocol 12 | nng_directory(survey0) 13 | 14 | nng_sources_if(NNG_PROTO_SURVEYOR0 survey.c xsurvey.c) 15 | nng_headers_if(NNG_PROTO_SURVEYOR0 nng/protocol/survey0/survey.h) 16 | nng_defines_if(NNG_PROTO_SURVEYOR0 NNG_HAVE_SURVEYOR0) 17 | 18 | nng_sources_if(NNG_PROTO_RESPONDENT0 respond.c xrespond.c) 19 | nng_headers_if(NNG_PROTO_RESPONDENT0 nng/protocol/survey0/respond.h) 20 | nng_defines_if(NNG_PROTO_RESPONDENT0 NNG_HAVE_RESPONDENT0) 21 | 22 | nng_test(respond_test) 23 | nng_test(survey_test) 24 | nng_test(xrespond_test) 25 | nng_test(xsurvey_test) -------------------------------------------------------------------------------- /src/sp/transport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Transports. 11 | nng_directory(transport) 12 | 13 | add_subdirectory(socket) 14 | add_subdirectory(inproc) 15 | add_subdirectory(ipc) 16 | add_subdirectory(tcp) 17 | add_subdirectory(tls) 18 | add_subdirectory(ws) 19 | add_subdirectory(zerotier) 20 | 21 | -------------------------------------------------------------------------------- /src/sp/transport/inproc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # inproc protocol 12 | nng_directory(inproc) 13 | 14 | nng_sources_if(NNG_TRANSPORT_INPROC inproc.c) 15 | nng_headers_if(NNG_TRANSPORT_INPROC nng/transport/inproc/inproc.h) 16 | nng_defines_if(NNG_TRANSPORT_INPROC NNG_TRANSPORT_INPROC) -------------------------------------------------------------------------------- /src/sp/transport/ipc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # ipc protocol 12 | nng_directory(ipc) 13 | 14 | nng_sources_if(NNG_TRANSPORT_IPC ipc.c) 15 | nng_headers_if(NNG_TRANSPORT_IPC nng/transport/ipc/ipc.h) 16 | nng_defines_if(NNG_TRANSPORT_IPC NNG_TRANSPORT_IPC) 17 | nng_test_if(NNG_TRANSPORT_IPC ipc_test) -------------------------------------------------------------------------------- /src/sp/transport/socket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # File Descriptor (or Handle) based connections 11 | nng_directory(socket) 12 | 13 | nng_sources_if(NNG_TRANSPORT_FDC sockfd.c) 14 | nng_defines_if(NNG_TRANSPORT_FDC NNG_TRANSPORT_FDC) 15 | nng_test(sockfd_test) -------------------------------------------------------------------------------- /src/sp/transport/tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # TCP protocol 12 | nng_directory(tcp) 13 | 14 | nng_sources_if(NNG_TRANSPORT_TCP tcp.c) 15 | nng_headers_if(NNG_TRANSPORT_TCP nng/transport/tcp/tcp.h) 16 | nng_defines_if(NNG_TRANSPORT_TCP NNG_TRANSPORT_TCP) 17 | nng_test(tcp_test) -------------------------------------------------------------------------------- /src/sp/transport/tls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # TLS transport 12 | nng_directory(tls) 13 | 14 | nng_sources_if(NNG_TRANSPORT_TLS tls.c) 15 | nng_headers_if(NNG_TRANSPORT_TLS nng/transport/tls/tls.h) 16 | nng_defines_if(NNG_TRANSPORT_TLS NNG_TRANSPORT_TLS) 17 | nng_test_if(NNG_ENABLE_TLS tls_tran_test) 18 | -------------------------------------------------------------------------------- /src/sp/transport/ws/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | # WebSocket transport 12 | nng_directory(ws) 13 | 14 | if (NNG_TRANSPORT_WS OR NNG_TRANSPORT_WSS) 15 | set(WS_ON ON) 16 | endif() 17 | 18 | nng_defines_if(NNG_TRANSPORT_WS NNG_TRANSPORT_WS) 19 | nng_defines_if(NNG_TRANSPORT_WSS NNG_TRANSPORT_WSS) 20 | nng_sources_if(WS_ON websocket.c) 21 | nng_headers_if(WS_ON nng/transport/ws/websocket.h) 22 | nng_test_if(WS_ON ws_test) 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/supplemental/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_directory(supplemental) 11 | 12 | add_subdirectory(base64) 13 | add_subdirectory(http) 14 | add_subdirectory(sha1) 15 | add_subdirectory(tls) 16 | add_subdirectory(util) 17 | add_subdirectory(websocket) 18 | add_subdirectory(mqtt) 19 | add_subdirectory(sqlite) 20 | add_subdirectory(quic) 21 | add_subdirectory(nanolib) 22 | add_subdirectory(scram) 23 | -------------------------------------------------------------------------------- /src/supplemental/README.adoc: -------------------------------------------------------------------------------- 1 | = supplemental sources 2 | 3 | This is for code that is not intrinsic to nng, but which may be used 4 | by multiple other subsystems. For example, common code for TLS support 5 | used by multiple transports is located here. 6 | -------------------------------------------------------------------------------- /src/supplemental/base64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_sources_if(NNG_SUPP_BASE64 11 | base64.c 12 | base64.h) 13 | 14 | nng_test_if(NNG_SUPP_BASE64 15 | base64_test) 16 | -------------------------------------------------------------------------------- /src/supplemental/http/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | option (NNG_ENABLE_HTTP "Enable HTTP API" ON) 12 | if (NNG_ENABLE_HTTP) 13 | set(NNG_SUPP_HTTP ON) 14 | endif() 15 | mark_as_advanced(NNG_ENABLE_HTTP) 16 | 17 | nng_sources(http_public.c http_api.h) 18 | nng_headers(nng/supplemental/http/http.h) 19 | 20 | nng_defines_if(NNG_SUPP_HTTP NNG_SUPP_HTTP) 21 | nng_sources_if(NNG_SUPP_HTTP 22 | http_client.c 23 | http_chunk.c 24 | http_conn.c 25 | http_msg.c 26 | http_public.c 27 | http_schemes.c 28 | http_server.c) 29 | -------------------------------------------------------------------------------- /src/supplemental/mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Mqtt. 11 | nng_directory(core) 12 | 13 | nng_check_sym(strlcpy string.h NNG_HAVE_STRLCPY) 14 | nng_check_sym(strnlen string.h NNG_HAVE_STRNLEN) 15 | nng_check_sym(strcasecmp string.h NNG_HAVE_STRCASECMP) 16 | nng_check_sym(strncasecmp string.h NNG_HAVE_STRNCASECMP) 17 | 18 | nng_sources( 19 | mqtt_public.c 20 | mqtt_codec.c 21 | mqtt_msg.c 22 | mqtt_msg.h 23 | mqtt_qos_db_api.c 24 | mqtt_qos_db_api.h 25 | ) 26 | 27 | nng_test(mqtt_test) 28 | 29 | nng_sources_if(NNG_ENABLE_SQLITE 30 | mqtt_qos_db.c 31 | mqtt_qos_db.h 32 | ) 33 | 34 | nng_test_if(NNG_ENABLE_SQLITE mqtt_qos_db_test) 35 | -------------------------------------------------------------------------------- /src/supplemental/nanolib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 NanoMQ Team, Inc. // 3 | # This software is supplied under the terms of the MIT License, a 4 | # copy of which should be located in the distribution where this 5 | # file was obtained (LICENSE.txt). A copy of the license may also be 6 | # found online at https://opensource.org/licenses/MIT. 7 | # 8 | 9 | nng_sources(file.c log.c base64.c) 10 | nng_headers(nng/supplemental/nanolib/file.h nng/supplemental/nanolib/log.h nng/supplemental/nanolib/base64.h) 11 | -------------------------------------------------------------------------------- /src/supplemental/scram/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | # 7 | 8 | if (NNG_ENABLE_SCRAM) 9 | nng_sources(scram.c scram.h) 10 | nng_test(scram_test) 11 | endif () 12 | -------------------------------------------------------------------------------- /src/supplemental/scram/scram.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2024 NanoMQ Team, Inc. 3 | // 4 | // This software is supplied under the terms of the MIT License, a 5 | // copy of which should be located in the distribution where this 6 | // file was obtained (LICENSE.txt). A copy of the license may also be 7 | // found online at https://opensource.org/licenses/MIT. 8 | // 9 | 10 | #ifndef NNG_SUPP_SCRAM_H 11 | #define NNG_SUPP_SCRAM_H 12 | 13 | enum SCRAM_digest { 14 | SCRAM_SHA1, 15 | SCRAM_SHA256 16 | }; 17 | 18 | void *scram_ctx_create(char *pwd, int pwdsz, int it_cnt, enum SCRAM_digest digest, int salt); 19 | void scram_ctx_free(void *ctx); 20 | 21 | char *scram_client_first_msg(void *arg, const char *username); 22 | 23 | char *scram_handle_client_first_msg(void *arg, const char *msg, int len); 24 | char *scram_handle_server_first_msg(void *arg, const char *msg, int len); 25 | char *scram_handle_client_final_msg(void *arg, const char *msg, int len); 26 | char *scram_handle_server_final_msg(void *arg, const char *msg, int len); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/supplemental/sha1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Staysail Systems, Inc. 3 | # Copyright 2017 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | nng_sources_if(NNG_SUPP_SHA1 sha1.c sha1.h) 12 | nng_test(sha1_test) 13 | -------------------------------------------------------------------------------- /src/supplemental/sha1/sha1.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #ifndef NNG_SUPPLEMENTAL_SHA1_SHA1_H 12 | #define NNG_SUPPLEMENTAL_SHA1_SHA1_H 13 | 14 | typedef struct { 15 | uint32_t digest[5]; // resulting digest 16 | uint64_t len; // length in bits 17 | uint8_t blk[64]; // message block 18 | int idx; // index of next byte in block 19 | } nni_sha1_ctx; 20 | 21 | extern void nni_sha1_init(nni_sha1_ctx *); 22 | extern void nni_sha1_update(nni_sha1_ctx *, const void *, size_t); 23 | extern void nni_sha1_final(nni_sha1_ctx *, uint8_t[20]); 24 | extern void nni_sha1(const void *, size_t, uint8_t[20]); 25 | 26 | #endif // NNG_SUPPLEMENTAL_SHA1_SHA1_H 27 | -------------------------------------------------------------------------------- /src/supplemental/sqlite/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This software is supplied under the terms of the MIT License, a 3 | # copy of which should be located in the distribution where this 4 | # file was obtained (LICENSE.txt). A copy of the license may also be 5 | # found online at https://opensource.org/licenses/MIT. 6 | # 7 | 8 | if (NNG_ENABLE_SQLITE) 9 | nng_sources(sqlite3.c sqlite3.h) 10 | 11 | if (NNG_PLATFORM_POSIX) 12 | nng_link_libraries(dl) 13 | elseif (NNG_PLATFORM_WINDOWS) 14 | nng_link_libraries(ws2_32) 15 | endif() 16 | 17 | nng_test(sqlite3_test) 18 | endif (NNG_ENABLE_SQLITE) 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/supplemental/sqlite/sqlite3_test.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "nuts.h" 7 | #include "sqlite3.h" 8 | 9 | void 10 | test_sqlite_write(void) 11 | { 12 | const int nCount = 500000; 13 | sqlite3 * db; 14 | TEST_CHECK(sqlite3_open("testdb.db", &db) == 0); 15 | TEST_CHECK( 16 | sqlite3_exec(db, "PRAGMA synchronous = OFF; ", 0, 0, 0) == 0); 17 | TEST_CHECK(sqlite3_exec(db, "drop table if exists t1", 0, 0, 0) == 0); 18 | TEST_CHECK( 19 | sqlite3_exec(db, 20 | "create table t1(id integer,x integer,y integer ,weight real)", 21 | 0, 0, 0) == 0); 22 | 23 | sqlite3_exec(db, "begin;", 0, 0, 0); 24 | sqlite3_stmt *stmt; 25 | const char * sql = "insert into t1 values(?,?,?,?)"; 26 | sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, 0); 27 | 28 | for (int i = 0; i < nCount; ++i) { 29 | sqlite3_reset(stmt); 30 | sqlite3_bind_int(stmt, 1, i); 31 | sqlite3_bind_int(stmt, 2, i * 2); 32 | sqlite3_bind_int(stmt, 3, i / 2); 33 | sqlite3_bind_double(stmt, 4, i * i); 34 | sqlite3_step(stmt); 35 | } 36 | sqlite3_finalize(stmt); 37 | 38 | TEST_CHECK(sqlite3_exec(db, "commit;", 0, 0, 0) == 0); 39 | 40 | TEST_CHECK(sqlite3_close(db) == 0); 41 | } 42 | 43 | TEST_LIST = { 44 | { "write", test_sqlite_write }, 45 | { NULL, NULL }, 46 | }; 47 | -------------------------------------------------------------------------------- /src/supplemental/tls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # Copyright 2018 Capitar IT Group BV 4 | # Copyright 2019 Devolutions 5 | # 6 | 7 | # 8 | # This software is supplied under the terms of the MIT License, a 9 | # copy of which should be located in the distribution where this 10 | # file was obtained (LICENSE.txt). A copy of the license may also be 11 | # found online at https://opensource.org/licenses/MIT. 12 | # 13 | 14 | if (NNG_ENABLE_TLS) 15 | set(NNG_TLS_ENGINES mbed wolf none) 16 | # We assume Mbed for now. (Someday replaced perhaps with Bear.) 17 | set(NNG_TLS_ENGINE mbed CACHE STRING "TLS engine to use.") 18 | set_property(CACHE NNG_TLS_ENGINE PROPERTY STRINGS ${NNG_TLS_ENGINES}) 19 | else () 20 | set(NNG_TLS_ENGINE none) 21 | endif () 22 | 23 | # default TLS implementation for now is Mbed. 24 | nng_headers(nng/supplemental/tls/tls.h) 25 | nng_headers(nng/supplemental/tls/engine.h) 26 | 27 | if (NOT NNG_TLS_ENGINE STREQUAL "none") 28 | nng_test(tls_test) 29 | endif () 30 | 31 | add_subdirectory(mbedtls) 32 | add_subdirectory(wolfssl) 33 | 34 | nng_sources(tls_common.c) 35 | nng_sources(tls_api.h) 36 | -------------------------------------------------------------------------------- /src/supplemental/tls/tls_api.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2020 Staysail Systems, Inc. 3 | // Copyright 2018 Capitar IT Group BV 4 | // Copyright 2019 Devolutions 5 | // 6 | // This software is supplied under the terms of the MIT License, a 7 | // copy of which should be located in the distribution where this 8 | // file was obtained (LICENSE.txt). A copy of the license may also be 9 | // found online at https://opensource.org/licenses/MIT. 10 | // 11 | 12 | #ifndef NNG_SUPPLEMENTAL_TLS_TLS_API_H 13 | #define NNG_SUPPLEMENTAL_TLS_TLS_API_H 14 | 15 | #include 16 | 17 | // The implementation supplies this function to create the TLS connection 18 | // object. All fields will be zeroed. 19 | extern int nni_tls_dialer_alloc(nng_stream_dialer **, const nng_url *); 20 | extern int nni_tls_listener_alloc(nng_stream_listener **, const nng_url *); 21 | 22 | #endif // NNG_SUPPLEMENTAL_TLS_TLS_API_H 23 | -------------------------------------------------------------------------------- /src/supplemental/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_sources(idhash.c options.c) 11 | nng_headers( 12 | nng/supplemental/util/idhash.h 13 | nng/supplemental/util/options.h 14 | nng/supplemental/util/platform.h) 15 | nng_test(idhash_test) 16 | -------------------------------------------------------------------------------- /src/supplemental/websocket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Staysail Systems, Inc. 3 | # Copyright 2017 Capitar IT Group BV 4 | # 5 | # This software is supplied under the terms of the MIT License, a 6 | # copy of which should be located in the distribution where this 7 | # file was obtained (LICENSE.txt). A copy of the license may also be 8 | # found online at https://opensource.org/licenses/MIT. 9 | # 10 | 11 | if (NNG_SUPP_WEBSOCKET) 12 | nng_sources(websocket.c websocket.h) 13 | else () 14 | nng_sources(stub.c) 15 | endif () 16 | nng_test(wssfile_test) 17 | nng_test(websocket_test) 18 | -------------------------------------------------------------------------------- /src/supplemental/websocket/stub.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2019 Staysail Systems, Inc. 3 | // Copyright 2019 Devolutions 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #include "core/nng_impl.h" 12 | 13 | // This stub file exists to support configuration of the stream subsystem 14 | // when websocket support is unconfigured. 15 | 16 | int 17 | nni_ws_dialer_alloc(nng_stream_dialer **dp, const nng_url *url) 18 | { 19 | NNI_ARG_UNUSED(dp); 20 | NNI_ARG_UNUSED(url); 21 | return (NNG_ENOTSUP); 22 | } 23 | 24 | int 25 | nni_ws_listener_alloc(nng_stream_listener **lp, const nng_url *url) 26 | { 27 | NNI_ARG_UNUSED(lp); 28 | NNI_ARG_UNUSED(url); 29 | return (NNG_ENOTSUP); 30 | } 31 | 32 | int 33 | nni_ws_checkopt(const char *name, const void *data, size_t sz, nni_type t) 34 | { 35 | NNI_ARG_UNUSED(name); 36 | NNI_ARG_UNUSED(data); 37 | NNI_ARG_UNUSED(sz); 38 | NNI_ARG_UNUSED(t); 39 | return (NNG_ENOTSUP); 40 | } 41 | -------------------------------------------------------------------------------- /src/testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Protocols. 11 | nng_directory(testing`) 12 | 13 | target_sources(nng_testing PRIVATE 14 | certs.c 15 | marry.c 16 | streams.c 17 | util.c) 18 | 19 | target_include_directories(nng_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 20 | -------------------------------------------------------------------------------- /src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | nng_directory(tools) 11 | 12 | add_subdirectory(nngcat) 13 | add_subdirectory(perf) 14 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_ambiguous_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # 7 | # This software is supplied under the terms of the MIT License, a 8 | # copy of which should be located in the distribution where this 9 | # file was obtained (LICENSE.txt). A copy of the license may also be 10 | # found online at https://opensource.org/licenses/MIT. 11 | # 12 | 13 | NNGCAT=${NNGCAT:=$1} 14 | NNGCAT=${NNGCAT:-./nngcat} 15 | CMD="${NNGCAT} --re --dial=tcp://127.0.0.1:27272" 16 | 17 | echo -n "Verify ambiguous options fail: " 18 | if ${CMD} >/dev/null 2>&1 19 | then 20 | echo "Failed: ambigous accepted" 21 | exit 1 22 | fi 23 | x=$(${CMD} 2>&1) 24 | if [[ ${x} =~ "ambiguous" ]] 25 | then 26 | echo "pass" 27 | exit 0 28 | fi 29 | 30 | echo "Failed: error did not match" 31 | exit 1 32 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_async_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # 7 | # This software is supplied under the terms of the MIT License, a 8 | # copy of which should be located in the distribution where this 9 | # file was obtained (LICENSE.txt). A copy of the license may also be 10 | # found online at https://opensource.org/licenses/MIT. 11 | # 12 | 13 | NNGCAT=${NNGCAT:=$1} 14 | NNGCAT=${NNGCAT:-./nngcat} 15 | ADDR="ipc:///tmp/nngcat_async_test" 16 | 17 | echo -n "Verify async connect: " 18 | 19 | ${NNGCAT} --async -d 1 --connect ${ADDR} --req0 -D "ping" & 20 | 21 | 22 | answer=$( ${NNGCAT} --rep0 --recv-timeout=3 --listen ${ADDR} -D "pong" --ascii 2>/dev/null ) 23 | 24 | if [[ ${answer} == "ping" ]] 25 | then 26 | echo "pass" 27 | exit 0 28 | fi 29 | 30 | echo "Failed: req did not match" 31 | echo "RES: $answer" 32 | exit 1 33 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_dup_proto_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # 7 | # This software is supplied under the terms of the MIT License, a 8 | # copy of which should be located in the distribution where this 9 | # file was obtained (LICENSE.txt). A copy of the license may also be 10 | # found online at https://opensource.org/licenses/MIT. 11 | # 12 | 13 | NNGCAT=${NNGCAT:=$1} 14 | NNGCAT=${NNGCAT:-./nngcat} 15 | 16 | echo -n "Verify only a single protocol is allowed: " 17 | if ${NNGCAT} --pub0 --sub0 --dial=tcp://127.0.0.1:8989 >/dev/null 2>&1 18 | then 19 | echo "Failed: duplicate protocols accepted" 20 | exit 1 21 | fi 22 | echo "pass" 23 | exit 0 24 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_help_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # 7 | # This software is supplied under the terms of the MIT License, a 8 | # copy of which should be located in the distribution where this 9 | # file was obtained (LICENSE.txt). A copy of the license may also be 10 | # found online at https://opensource.org/licenses/MIT. 11 | # 12 | 13 | NNGCAT=${NNGCAT:=$1} 14 | NNGCAT=${NNGCAT:-./nngcat} 15 | 16 | echo -n "Verify nngcat help: " 17 | if ${NNGCAT} --help >/dev/null 2>&1 18 | then 19 | echo "Failed: help didn't return 1" 20 | exit 1 21 | fi 22 | x=$(${NNGCAT} --help 2>&1) 23 | if [[ ${x} =~ "Usage:" ]] 24 | then 25 | echo "pass" 26 | exit 0 27 | fi 28 | 29 | echo "Failed: usage did not match" 30 | echo "Output:" 31 | echo "$x" 32 | exit 1 33 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_need_proto_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # 7 | # This software is supplied under the terms of the MIT License, a 8 | # copy of which should be located in the distribution where this 9 | # file was obtained (LICENSE.txt). A copy of the license may also be 10 | # found online at https://opensource.org/licenses/MIT. 11 | # 12 | 13 | NNGCAT=${NNGCAT:=$1} 14 | NNGCAT=${NNGCAT:-./nngcat} 15 | 16 | echo -n "Verify a protocol is needed: " 17 | if ${NNGCAT} --dial=tcp://127.0.0.1:8989 >/dev/null 2>&1 18 | then 19 | echo "Failed: protocol should be required" 20 | exit 1 21 | fi 22 | echo "pass" 23 | exit 0 24 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_stdin_pipe_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # Copyright 2020 Lager Data, Inc. 7 | # 8 | # This software is supplied under the terms of the MIT License, a 9 | # copy of which should be located in the distribution where this 10 | # file was obtained (LICENSE.txt). A copy of the license may also be 11 | # found online at https://opensource.org/licenses/MIT. 12 | # 13 | 14 | NNGCAT=${NNGCAT:=$1} 15 | NNGCAT=${NNGCAT:-./nngcat} 16 | ADDR="ipc:///tmp/nngcat_stdin_pipe_test" 17 | OUTPUT=/tmp/nngcat_stdin_pipe_test.$$.out 18 | 19 | echo -n "Verify reading from stdin pipe: " 20 | 21 | trap "rm $OUTPUT" 0 22 | 23 | ${NNGCAT} --listen ${ADDR} --count=1 --recv-timeout=3 --recv-maxsz=0 --pull0 --raw > $OUTPUT 2>/dev/null & 24 | bgid=$! 25 | 26 | sleep 1 27 | # for speed of execution, run these in the background, they should be ignored 28 | echo "hello world" | ${NNGCAT} --connect ${ADDR} --delay=1 --push0 --file - 29 | wait "$bgid" 2>/dev/null 30 | 31 | sum=$(cksum ${OUTPUT}) 32 | sum=${sum%% *} 33 | 34 | # This matches "hello world\n" since echo adds a trailing newline 35 | if [[ ${sum} == 3733384285 ]] 36 | then 37 | echo "pass" 38 | exit 0 39 | fi 40 | echo "FAIL: Checksum failed (Wanted 3733384285 got ${sum})" 41 | echo "OUTPUT:" 42 | ls -la ${OUTPUT} 43 | 44 | exit 1 45 | -------------------------------------------------------------------------------- /src/tools/nngcat/nngcat_unlimited_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright 2018 Staysail Systems, Inc. 5 | # Copyright 2018 Capitar IT Group BV 6 | # 7 | # This software is supplied under the terms of the MIT License, a 8 | # copy of which should be located in the distribution where this 9 | # file was obtained (LICENSE.txt). A copy of the license may also be 10 | # found online at https://opensource.org/licenses/MIT. 11 | # 12 | 13 | NNGCAT=${NNGCAT:=$1} 14 | NNGCAT=${NNGCAT:-./nngcat} 15 | ADDR="ipc:///tmp/nngcat_unlimited_test" 16 | INPUT=/tmp/nngcat_unlimited_test.$$.in 17 | OUTPUT=/tmp/nngcat_unlimited_test.$$.out 18 | 19 | echo -n "Verify unlimited receive size: " 20 | 21 | trap "rm $OUTPUT $INPUT" 0 22 | 23 | # 4 MB 24 | dd if=/dev/urandom of=${INPUT} bs=1024 count=4096 >/dev/null 2>&1 25 | goodsum=$(cksum ${INPUT}) 26 | goodsum=${goodsum%% *} 27 | 28 | ${NNGCAT} --listen ${ADDR} --count=1 --recv-maxsz=0 --pull0 --raw > $OUTPUT 2>/dev/null & 29 | sleep 1 30 | # for speed of execution, run these in the background, they should be ignored 31 | ${NNGCAT} --connect ${ADDR} --delay=1 --push0 --file ${INPUT} 32 | wait $bgid 2>/dev/null 33 | 34 | sum=$(cksum ${OUTPUT}) 35 | sum=${sum%% *} 36 | 37 | if [[ ${sum} == ${goodsum} ]] 38 | then 39 | echo "pass" 40 | exit 0 41 | fi 42 | echo "FAIL: Checksum failed (Wanted ${goodsum} got ${sum})" 43 | echo "OUTPUT:" 44 | ls -la ${OUTPUT} 45 | 46 | exit 1 47 | -------------------------------------------------------------------------------- /src/tools/perf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Staysail Systems, Inc. 3 | # 4 | # This software is supplied under the terms of the MIT License, a 5 | # copy of which should be located in the distribution where this 6 | # file was obtained (LICENSE.txt). A copy of the license may also be 7 | # found online at https://opensource.org/licenses/MIT. 8 | # 9 | 10 | # Build performance tests. 11 | 12 | nng_directory(perf) 13 | 14 | if (NNG_TESTS) 15 | macro (add_nng_perf NAME) 16 | add_executable (${NAME} perf.c) 17 | target_link_libraries (${NAME} nng nng_private) 18 | endmacro (add_nng_perf) 19 | 20 | add_nng_perf(remote_lat) 21 | add_nng_perf(local_lat) 22 | add_nng_perf(local_thr) 23 | add_nng_perf(remote_thr) 24 | add_nng_perf(inproc_thr) 25 | add_nng_perf(inproc_lat) 26 | 27 | add_test (NAME nng.inproc_lat COMMAND inproc_lat 64 10000) 28 | set_tests_properties (nng.inproc_lat PROPERTIES TIMEOUT 30) 29 | 30 | add_test (NAME nng.inproc_thr COMMAND inproc_thr 1400 10000) 31 | set_tests_properties (nng.inproc_thr PROPERTIES TIMEOUT 30) 32 | 33 | add_executable (pubdrop pubdrop.c) 34 | target_link_libraries(pubdrop nng nng_private) 35 | endif () 36 | -------------------------------------------------------------------------------- /tests/README.adoc: -------------------------------------------------------------------------------- 1 | == About C-Convey 2 | 3 | The convey framework in this directory was originally started for 4 | this project, but has since been promoted to a project of it's own. 5 | Please see it's home page on https://github.com/gdamore/c-convey[github] 6 | for updates and further information. 7 | 8 | The convey framework is licensed under the same terms as the rest 9 | of this project (MIT style license). 10 | 11 | Having said that, we are moving towards a new testing infrastructure. 12 | See the acutest.h header in this directory, along with testutil.h. 13 | 14 | Please do not write new tests in c-convey format. -------------------------------------------------------------------------------- /tests/inproc.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2021 Staysail Systems, Inc. 3 | // Copyright 2017 Capitar IT Group BV 4 | // 5 | // This software is supplied under the terms of the MIT License, a 6 | // copy of which should be located in the distribution where this 7 | // file was obtained (LICENSE.txt). A copy of the license may also be 8 | // found online at https://opensource.org/licenses/MIT. 9 | // 10 | 11 | #include "convey.h" 12 | #include "trantest.h" 13 | 14 | #include "core/nng_impl.h" 15 | 16 | // Inproc tests. 17 | 18 | TestMain("Inproc Transport", { 19 | trantest_test_all("inproc://TEST_%u"); 20 | }) 21 | --------------------------------------------------------------------------------