From 98f23e10cc1d65da6a7f6c7e4f5665d7afc27a86 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 15 Mar 2018 08:40:17 -0700 Subject: [PATCH] fixes #286 nng_pair0_open (and all others) need man page fixes #279 consider restructuring man sections This represents a rather significant rework, and major editing effort, for the entire set of manual pages. All of the pages now have a section number in their filename; this assists in some other tooling, particularly ebook generation as every link needs to be programmatically modified when combined into an ebook. Section 5 is introduced, and populated with pages for the main types, and all options are now documented. Numerous errors have been corrected, including rewriting certain portions such as the header section of the surveyor protocol. Much work has been done to facilitate index generation, although certainly more work remains here. Every internal link within these pages now resolves; there are no more dead links. (This is required to generate Kindle format books.) --- docs/man/libnng.3.adoc | 319 ++++++++++++++++++ docs/man/libnng.adoc | 318 ----------------- docs/man/man1.desc | 2 + docs/man/man1.sect | 1 + docs/man/man3.desc | 2 + docs/man/man3.sect | 1 + docs/man/man3compat.desc | 1 + docs/man/man3compat.sect | 1 + docs/man/man3http.desc | 2 + docs/man/man3http.sect | 1 + docs/man/man3tls.desc | 1 + docs/man/man3tls.sect | 1 + docs/man/man5.desc | 1 + docs/man/man5.sect | 1 + docs/man/man7.desc | 2 + docs/man/man7.sect | 1 + docs/man/{nng.adoc => nng.7.adoc} | 46 +-- docs/man/nng_aio.5.adoc | 69 ++++ ...ng_aio_abort.adoc => nng_aio_abort.3.adoc} | 18 +- docs/man/nng_aio_alloc.3.adoc | 80 +++++ docs/man/nng_aio_alloc.adoc | 77 ----- ..._aio_cancel.adoc => nng_aio_cancel.3.adoc} | 18 +- ...ng_aio_count.adoc => nng_aio_count.3.adoc} | 26 +- ..._aio_finish.adoc => nng_aio_finish.3.adoc} | 29 +- ...{nng_aio_free.adoc => nng_aio_free.3.adoc} | 13 +- ...et_input.adoc => nng_aio_get_input.3.adoc} | 24 +- docs/man/nng_aio_get_msg.3.adoc | 48 +++ ..._output.adoc => nng_aio_get_output.3.adoc} | 17 +- ..._aio_result.adoc => nng_aio_result.3.adoc} | 25 +- ...et_input.adoc => nng_aio_set_input.3.adoc} | 26 +- ...io_set_iov.adoc => nng_aio_set_iov.3.adoc} | 25 +- docs/man/nng_aio_set_msg.3.adoc | 46 +++ ..._output.adoc => nng_aio_set_output.3.adoc} | 21 +- ...imeout.adoc => nng_aio_set_timeout.3.adoc} | 28 +- ...{nng_aio_stop.adoc => nng_aio_stop.3.adoc} | 21 +- ...{nng_aio_wait.adoc => nng_aio_wait.3.adoc} | 14 +- docs/man/{nng_alloc.adoc => nng_alloc.3.adoc} | 19 +- docs/man/nng_bus.7.adoc | 74 ++++ docs/man/nng_bus.adoc | 71 ---- docs/man/nng_bus_open.3.adoc | 44 +++ docs/man/{nng_close.adoc => nng_close.3.adoc} | 22 +- docs/man/nng_compat.3compat.adoc | 96 ++++++ docs/man/nng_device.3.adoc | 104 ++++++ docs/man/{nng_dial.adoc => nng_dial.3.adoc} | 50 +-- docs/man/nng_dialer.5.adoc | 67 ++++ ...ler_close.adoc => nng_dialer_close.3.adoc} | 30 +- ...r_create.adoc => nng_dialer_create.3.adoc} | 46 +-- ...r_getopt.adoc => nng_dialer_getopt.3.adoc} | 21 +- ...r_setopt.adoc => nng_dialer_setopt.3.adoc} | 32 +- ...ler_start.adoc => nng_dialer_start.3.adoc} | 19 +- ...{nng_duration.adoc => nng_duration.5.adoc} | 18 +- docs/man/{nng_free.adoc => nng_free.3.adoc} | 17 +- .../{nng_getopt.adoc => nng_getopt.3.adoc} | 20 +- ....adoc => nng_http_client_alloc.3http.adoc} | 12 +- ...doc => nng_http_client_connect.3http.adoc} | 24 +- ...e.adoc => nng_http_client_free.3http.adoc} | 10 +- ...doc => nng_http_client_get_tls.3http.adoc} | 14 +- ...doc => nng_http_client_set_tls.3http.adoc} | 23 +- ...se.adoc => nng_http_conn_close.3http.adoc} | 14 +- ...ead.adoc => nng_http_conn_read.3http.adoc} | 44 +-- ...adoc => nng_http_conn_read_all.3http.adoc} | 28 +- ...adoc => nng_http_conn_read_req.3http.adoc} | 33 +- ...adoc => nng_http_conn_read_res.3http.adoc} | 30 +- ...te.adoc => nng_http_conn_write.3http.adoc} | 44 +-- ...doc => nng_http_conn_write_all.3http.adoc} | 66 ++-- ...doc => nng_http_conn_write_req.3http.adoc} | 39 +-- ...doc => nng_http_conn_write_res.3http.adoc} | 39 +-- ...adoc => nng_http_handler_alloc.3http.adoc} | 88 ++--- ....adoc => nng_http_handler_free.3http.adoc} | 14 +- ...c => nng_http_handler_get_data.3http.adoc} | 16 +- ...c => nng_http_handler_set_data.3http.adoc} | 23 +- ...c => nng_http_handler_set_host.3http.adoc} | 19 +- ...=> nng_http_handler_set_method.3http.adoc} | 21 +- ...c => nng_http_handler_set_tree.3http.adoc} | 14 +- ...hijack.adoc => nng_http_hijack.3http.adoc} | 30 +- ...doc => nng_http_req_add_header.3http.adoc} | 21 +- docs/man/nng_http_req_alloc.3http.adoc | 61 ++++ docs/man/nng_http_req_alloc.adoc | 60 ---- ...adoc => nng_http_req_copy_data.3http.adoc} | 24 +- ...doc => nng_http_req_del_header.3http.adoc} | 19 +- ...free.adoc => nng_http_req_free.3http.adoc} | 10 +- ...doc => nng_http_req_get_header.3http.adoc} | 17 +- ...doc => nng_http_req_get_method.3http.adoc} | 15 +- ...i.adoc => nng_http_req_get_uri.3http.adoc} | 17 +- ...oc => nng_http_req_get_version.3http.adoc} | 12 +- ....adoc => nng_http_req_set_data.3http.adoc} | 16 +- ...doc => nng_http_req_set_header.3http.adoc} | 24 +- ...doc => nng_http_req_set_method.3http.adoc} | 8 +- ...i.adoc => nng_http_req_set_uri.3http.adoc} | 22 +- ...oc => nng_http_req_set_version.3http.adoc} | 19 +- ...doc => nng_http_res_add_header.3http.adoc} | 21 +- docs/man/nng_http_res_alloc.3http.adoc | 65 ++++ docs/man/nng_http_res_alloc.adoc | 64 ---- ...oc => nng_http_res_alloc_error.3http.adoc} | 28 +- ...adoc => nng_http_res_copy_data.3http.adoc} | 24 +- ...doc => nng_http_res_del_header.3http.adoc} | 16 +- ...free.adoc => nng_http_res_free.3http.adoc} | 10 +- ...doc => nng_http_res_get_header.3http.adoc} | 17 +- ...doc => nng_http_res_get_reason.3http.adoc} | 21 +- ...doc => nng_http_res_get_status.3http.adoc} | 16 +- ...oc => nng_http_res_get_version.3http.adoc} | 12 +- ....adoc => nng_http_res_set_data.3http.adoc} | 20 +- ...doc => nng_http_res_set_header.3http.adoc} | 24 +- ...doc => nng_http_res_set_reason.3http.adoc} | 16 +- ...doc => nng_http_res_set_status.3http.adoc} | 22 +- ...oc => nng_http_res_set_version.3http.adoc} | 23 +- ...=> nng_http_server_add_handler.3http.adoc} | 18 +- ...=> nng_http_server_del_handler.3http.adoc} | 16 +- ...doc => nng_http_server_get_tls.3http.adoc} | 18 +- ...d.adoc => nng_http_server_hold.3http.adoc} | 32 +- ...doc => nng_http_server_release.3http.adoc} | 12 +- ...doc => nng_http_server_set_tls.3http.adoc} | 26 +- ....adoc => nng_http_server_start.3http.adoc} | 18 +- ...p.adoc => nng_http_server_stop.3http.adoc} | 8 +- .../{nng_inproc.adoc => nng_inproc.7.adoc} | 46 +-- docs/man/nng_inproc_register.3.adoc | 42 +++ docs/man/nng_iov.5.adoc | 54 +++ docs/man/nng_ipc.7.adoc | 73 ++++ docs/man/nng_ipc.adoc | 83 ----- docs/man/nng_ipc_register.3.adoc | 42 +++ .../{nng_listen.adoc => nng_listen.3.adoc} | 49 +-- docs/man/nng_listener.5.adoc | 64 ++++ ...r_close.adoc => nng_listener_close.3.adoc} | 22 +- docs/man/nng_listener_create.3.adoc | 75 ++++ docs/man/nng_listener_create.adoc | 72 ---- ...getopt.adoc => nng_listener_getopt.3.adoc} | 21 +- ...setopt.adoc => nng_listener_setopt.3.adoc} | 22 +- ...r_start.adoc => nng_listener_start.3.adoc} | 26 +- docs/man/nng_msg.5.adoc | 70 ++++ ...ng_msg_alloc.adoc => nng_msg_alloc.3.adoc} | 23 +- ..._msg_append.adoc => nng_msg_append.3.adoc} | 26 +- ...{nng_msg_body.adoc => nng_msg_body.3.adoc} | 36 +- ...{nng_msg_chop.adoc => nng_msg_chop.3.adoc} | 29 +- ...ng_msg_clear.adoc => nng_msg_clear.3.adoc} | 9 +- .../{nng_msg_dup.adoc => nng_msg_dup.3.adoc} | 18 +- ...{nng_msg_free.adoc => nng_msg_free.3.adoc} | 11 +- ..._get_pipe.adoc => nng_msg_get_pipe.3.adoc} | 27 +- ..._msg_header.adoc => nng_msg_header.3.adoc} | 27 +- ...pend.adoc => nng_msg_header_append.3.adoc} | 28 +- ...r_chop.adoc => nng_msg_header_chop.3.adoc} | 23 +- ...clear.adoc => nng_msg_header_clear.3.adoc} | 10 +- ...sert.adoc => nng_msg_header_insert.3.adoc} | 25 +- ...der_len.adoc => nng_msg_header_len.3.adoc} | 11 +- ...r_trim.adoc => nng_msg_header_trim.3.adoc} | 24 +- ..._msg_insert.adoc => nng_msg_insert.3.adoc} | 35 +- .../{nng_msg_len.adoc => nng_msg_len.3.adoc} | 11 +- ...sg_realloc.adoc => nng_msg_realloc.3.adoc} | 40 ++- ..._set_pipe.adoc => nng_msg_set_pipe.3.adoc} | 20 +- ...{nng_msg_trim.adoc => nng_msg_trim.3.adoc} | 26 +- .../{nng_options.adoc => nng_options.5.adoc} | 87 ++--- docs/man/{nng_pair.adoc => nng_pair.7.adoc} | 78 ++--- docs/man/nng_pair_open.3.adoc | 53 +++ docs/man/nng_pipe.5.adoc | 57 ++++ docs/man/nng_pipe_close.3.adoc | 51 +++ ...ipe_getopt.adoc => nng_pipe_getopt.3.adoc} | 89 ++--- docs/man/nng_pub.7.adoc | 70 ++++ docs/man/nng_pub.adoc | 66 ---- docs/man/nng_pub_open.3.adoc | 45 +++ docs/man/{nng_pull.adoc => nng_pull.7.adoc} | 31 +- docs/man/nng_pull_open.3.adoc | 45 +++ docs/man/nng_push.7.adoc | 72 ++++ docs/man/nng_push.adoc | 71 ---- docs/man/nng_push_open.3.adoc | 45 +++ docs/man/{nng_recv.adoc => nng_recv.3.adoc} | 47 +-- docs/man/nng_recv_aio.3.adoc | 79 +++++ .../{nng_recvmsg.adoc => nng_recvmsg.3.adoc} | 26 +- docs/man/nng_rep.7.adoc | 75 ++++ docs/man/nng_rep.adoc | 83 ----- docs/man/nng_rep_open.3.adoc | 45 +++ docs/man/{nng_req.adoc => nng_req.7.adoc} | 88 ++--- docs/man/nng_req_open.3.adoc | 45 +++ docs/man/nng_respondent.7.adoc | 79 +++++ docs/man/nng_respondent.adoc | 90 ----- docs/man/nng_respondent_open.3.adoc | 47 +++ docs/man/{nng_send.adoc => nng_send.3.adoc} | 57 ++-- docs/man/nng_send_aio.3.adoc | 88 +++++ .../{nng_sendmsg.adoc => nng_sendmsg.3.adoc} | 55 +-- .../{nng_setopt.adoc => nng_setopt.3.adoc} | 33 +- ...ng_sleep_aio.adoc => nng_sleep_aio.3.adoc} | 18 +- ...{nng_sockaddr.adoc => nng_sockaddr.5.adoc} | 66 ++-- docs/man/nng_sockaddr_in.5.adoc | 70 ++++ docs/man/nng_sockaddr_in6.5.adoc | 71 ++++ docs/man/nng_sockaddr_inproc.5.adoc | 58 ++++ docs/man/nng_sockaddr_ipc.5.adoc | 70 ++++ docs/man/nng_sockaddr_zt.5.adoc | 81 +++++ .../{nng_socket.adoc => nng_socket.5.adoc} | 31 +- ...{nng_strerror.adoc => nng_strerror.3.adoc} | 11 +- docs/man/{nng_sub.adoc => nng_sub.7.adoc} | 47 +-- docs/man/nng_sub_open.3.adoc | 45 +++ docs/man/nng_surveyor.7.adoc | 131 +++++++ docs/man/nng_surveyor.adoc | 107 ------ docs/man/nng_surveyor_open.3.adoc | 46 +++ docs/man/nng_tcp.7.adoc | 93 +++++ docs/man/nng_tcp.adoc | 115 ------- docs/man/nng_tcp_register.3.adoc | 42 +++ docs/man/{nng_tls.adoc => nng_tls.7.adoc} | 114 +++---- ...oc.adoc => nng_tls_config_alloc.3tls.adoc} | 22 +- ...doc => nng_tls_config_auth_mode.3tls.adoc} | 36 +- ...adoc => nng_tls_config_ca_chain.3tls.adoc} | 24 +- ....adoc => nng_tls_config_ca_file.3tls.adoc} | 26 +- ...=> nng_tls_config_cert_key_file.3tls.adoc} | 28 +- ...ree.adoc => nng_tls_config_free.3tls.adoc} | 10 +- ...adoc => nng_tls_config_own_cert.3tls.adoc} | 26 +- ...c => nng_tls_config_server_name.3tls.adoc} | 22 +- docs/man/nng_tls_register.3.adoc | 42 +++ ...ng_url_clone.adoc => nng_url_clone.3.adoc} | 16 +- ...{nng_url_free.adoc => nng_url_free.3.adoc} | 8 +- ...ng_url_parse.adoc => nng_url_parse.3.adoc} | 8 +- .../{nng_version.adoc => nng_version.3.adoc} | 10 +- docs/man/{nng_ws.adoc => nng_ws.7.adoc} | 137 ++++---- docs/man/nng_ws_register.3.adoc | 42 +++ docs/man/nng_wss_register.3.adoc | 42 +++ ...{nng_zerotier.adoc => nng_zerotier.7.adoc} | 127 ++++--- docs/man/nng_zerotier_register.3.adoc | 42 +++ docs/man/{nngcat.adoc => nngcat.1.adoc} | 121 +++---- docs/man/preview.sh | 18 +- 216 files changed, 5403 insertions(+), 3250 deletions(-) create mode 100644 docs/man/libnng.3.adoc delete mode 100644 docs/man/libnng.adoc create mode 100644 docs/man/man1.desc create mode 100644 docs/man/man1.sect create mode 100644 docs/man/man3.desc create mode 100644 docs/man/man3.sect create mode 100644 docs/man/man3compat.desc create mode 100644 docs/man/man3compat.sect create mode 100644 docs/man/man3http.desc create mode 100644 docs/man/man3http.sect create mode 100644 docs/man/man3tls.desc create mode 100644 docs/man/man3tls.sect create mode 100644 docs/man/man5.desc create mode 100644 docs/man/man5.sect create mode 100644 docs/man/man7.desc create mode 100644 docs/man/man7.sect rename docs/man/{nng.adoc => nng.7.adoc} (80%) create mode 100644 docs/man/nng_aio.5.adoc rename docs/man/{nng_aio_abort.adoc => nng_aio_abort.3.adoc} (75%) create mode 100644 docs/man/nng_aio_alloc.3.adoc delete mode 100644 docs/man/nng_aio_alloc.adoc rename docs/man/{nng_aio_cancel.adoc => nng_aio_cancel.3.adoc} (70%) rename docs/man/{nng_aio_count.adoc => nng_aio_count.3.adoc} (70%) rename docs/man/{nng_aio_finish.adoc => nng_aio_finish.3.adoc} (56%) rename docs/man/{nng_aio_free.adoc => nng_aio_free.3.adoc} (81%) rename docs/man/{nng_aio_get_input.adoc => nng_aio_get_input.3.adoc} (65%) create mode 100644 docs/man/nng_aio_get_msg.3.adoc rename docs/man/{nng_aio_get_output.adoc => nng_aio_get_output.3.adoc} (79%) rename docs/man/{nng_aio_result.adoc => nng_aio_result.3.adoc} (72%) rename docs/man/{nng_aio_set_input.adoc => nng_aio_set_input.3.adoc} (67%) rename docs/man/{nng_aio_set_iov.adoc => nng_aio_set_iov.3.adoc} (75%) create mode 100644 docs/man/nng_aio_set_msg.3.adoc rename docs/man/{nng_aio_set_output.adoc => nng_aio_set_output.3.adoc} (76%) rename docs/man/{nng_aio_set_timeout.adoc => nng_aio_set_timeout.3.adoc} (65%) rename docs/man/{nng_aio_stop.adoc => nng_aio_stop.3.adoc} (70%) rename docs/man/{nng_aio_wait.adoc => nng_aio_wait.3.adoc} (81%) rename docs/man/{nng_alloc.adoc => nng_alloc.3.adoc} (78%) create mode 100644 docs/man/nng_bus.7.adoc delete mode 100644 docs/man/nng_bus.adoc create mode 100644 docs/man/nng_bus_open.3.adoc rename docs/man/{nng_close.adoc => nng_close.3.adoc} (56%) create mode 100644 docs/man/nng_compat.3compat.adoc create mode 100644 docs/man/nng_device.3.adoc rename docs/man/{nng_dial.adoc => nng_dial.3.adoc} (63%) create mode 100644 docs/man/nng_dialer.5.adoc rename docs/man/{nng_dialer_close.adoc => nng_dialer_close.3.adoc} (63%) rename docs/man/{nng_dialer_create.adoc => nng_dialer_create.3.adoc} (57%) rename docs/man/{nng_dialer_getopt.adoc => nng_dialer_getopt.3.adoc} (91%) rename docs/man/{nng_dialer_setopt.adoc => nng_dialer_setopt.3.adoc} (83%) rename docs/man/{nng_dialer_start.adoc => nng_dialer_start.3.adoc} (86%) rename docs/man/{nng_duration.adoc => nng_duration.5.adoc} (76%) rename docs/man/{nng_free.adoc => nng_free.3.adoc} (76%) rename docs/man/{nng_getopt.adoc => nng_getopt.3.adoc} (89%) rename docs/man/{nng_http_client_alloc.adoc => nng_http_client_alloc.3http.adoc} (80%) rename docs/man/{nng_http_client_connect.adoc => nng_http_client_connect.3http.adoc} (79%) rename docs/man/{nng_http_client_free.adoc => nng_http_client_free.3http.adoc} (77%) rename docs/man/{nng_http_client_get_tls.adoc => nng_http_client_get_tls.3http.adoc} (76%) rename docs/man/{nng_http_client_set_tls.adoc => nng_http_client_set_tls.3http.adoc} (66%) rename docs/man/{nng_http_conn_close.adoc => nng_http_conn_close.3http.adoc} (79%) rename docs/man/{nng_http_conn_read.adoc => nng_http_conn_read.3http.adoc} (58%) rename docs/man/{nng_http_conn_read_all.adoc => nng_http_conn_read_all.3http.adoc} (78%) rename docs/man/{nng_http_conn_read_req.adoc => nng_http_conn_read_req.3http.adoc} (63%) rename docs/man/{nng_http_conn_read_res.adoc => nng_http_conn_read_res.3http.adoc} (69%) rename docs/man/{nng_http_conn_write.adoc => nng_http_conn_write.3http.adoc} (61%) rename docs/man/{nng_http_conn_write_all.adoc => nng_http_conn_write_all.3http.adoc} (51%) rename docs/man/{nng_http_conn_write_req.adoc => nng_http_conn_write_req.3http.adoc} (56%) rename docs/man/{nng_http_conn_write_res.adoc => nng_http_conn_write_res.3http.adoc} (62%) rename docs/man/{nng_http_handler_alloc.adoc => nng_http_handler_alloc.3http.adoc} (59%) rename docs/man/{nng_http_handler_free.adoc => nng_http_handler_free.3http.adoc} (75%) rename docs/man/{nng_http_handler_get_data.adoc => nng_http_handler_get_data.3http.adoc} (70%) rename docs/man/{nng_http_handler_set_data.adoc => nng_http_handler_set_data.3http.adoc} (68%) rename docs/man/{nng_http_handler_set_host.adoc => nng_http_handler_set_host.3http.adoc} (77%) rename docs/man/{nng_http_handler_set_method.adoc => nng_http_handler_set_method.3http.adoc} (73%) rename docs/man/{nng_http_handler_set_tree.adoc => nng_http_handler_set_tree.3http.adoc} (80%) rename docs/man/{nng_http_hijack.adoc => nng_http_hijack.3http.adoc} (67%) rename docs/man/{nng_http_req_add_header.adoc => nng_http_req_add_header.3http.adoc} (76%) create mode 100644 docs/man/nng_http_req_alloc.3http.adoc delete mode 100644 docs/man/nng_http_req_alloc.adoc rename docs/man/{nng_http_req_copy_data.adoc => nng_http_req_copy_data.3http.adoc} (67%) rename docs/man/{nng_http_req_del_header.adoc => nng_http_req_del_header.3http.adoc} (73%) rename docs/man/{nng_http_req_free.adoc => nng_http_req_free.3http.adoc} (86%) rename docs/man/{nng_http_req_get_header.adoc => nng_http_req_get_header.3http.adoc} (76%) rename docs/man/{nng_http_req_get_method.adoc => nng_http_req_get_method.3http.adoc} (74%) rename docs/man/{nng_http_req_get_uri.adoc => nng_http_req_get_uri.3http.adoc} (72%) rename docs/man/{nng_http_req_get_version.adoc => nng_http_req_get_version.3http.adoc} (81%) rename docs/man/{nng_http_req_set_data.adoc => nng_http_req_set_data.3http.adoc} (76%) rename docs/man/{nng_http_req_set_header.adoc => nng_http_req_set_header.3http.adoc} (69%) rename docs/man/{nng_http_req_set_method.adoc => nng_http_req_set_method.3http.adoc} (87%) rename docs/man/{nng_http_req_set_uri.adoc => nng_http_req_set_uri.3http.adoc} (73%) rename docs/man/{nng_http_req_set_version.adoc => nng_http_req_set_version.3http.adoc} (72%) rename docs/man/{nng_http_res_add_header.adoc => nng_http_res_add_header.3http.adoc} (77%) create mode 100644 docs/man/nng_http_res_alloc.3http.adoc delete mode 100644 docs/man/nng_http_res_alloc.adoc rename docs/man/{nng_http_res_alloc_error.adoc => nng_http_res_alloc_error.3http.adoc} (65%) rename docs/man/{nng_http_res_copy_data.adoc => nng_http_res_copy_data.3http.adoc} (67%) rename docs/man/{nng_http_res_del_header.adoc => nng_http_res_del_header.3http.adoc} (78%) rename docs/man/{nng_http_res_free.adoc => nng_http_res_free.3http.adoc} (86%) rename docs/man/{nng_http_res_get_header.adoc => nng_http_res_get_header.3http.adoc} (76%) rename docs/man/{nng_http_res_get_reason.adoc => nng_http_res_get_reason.3http.adoc} (63%) rename docs/man/{nng_http_res_get_status.adoc => nng_http_res_get_status.3http.adoc} (92%) rename docs/man/{nng_http_res_get_version.adoc => nng_http_res_get_version.3http.adoc} (81%) rename docs/man/{nng_http_res_set_data.adoc => nng_http_res_set_data.3http.adoc} (76%) rename docs/man/{nng_http_res_set_header.adoc => nng_http_res_set_header.3http.adoc} (69%) rename docs/man/{nng_http_res_set_reason.adoc => nng_http_res_set_reason.3http.adoc} (80%) rename docs/man/{nng_http_res_set_status.adoc => nng_http_res_set_status.3http.adoc} (89%) rename docs/man/{nng_http_res_set_version.adoc => nng_http_res_set_version.3http.adoc} (72%) rename docs/man/{nng_http_server_add_handler.adoc => nng_http_server_add_handler.3http.adoc} (77%) rename docs/man/{nng_http_server_del_handler.adoc => nng_http_server_del_handler.3http.adoc} (76%) rename docs/man/{nng_http_server_get_tls.adoc => nng_http_server_get_tls.3http.adoc} (75%) rename docs/man/{nng_http_server_hold.adoc => nng_http_server_hold.3http.adoc} (63%) rename docs/man/{nng_http_server_release.adoc => nng_http_server_release.3http.adoc} (79%) rename docs/man/{nng_http_server_set_tls.adoc => nng_http_server_set_tls.3http.adoc} (65%) rename docs/man/{nng_http_server_start.adoc => nng_http_server_start.3http.adoc} (77%) rename docs/man/{nng_http_server_stop.adoc => nng_http_server_stop.3http.adoc} (83%) rename docs/man/{nng_inproc.adoc => nng_inproc.7.adoc} (55%) create mode 100644 docs/man/nng_inproc_register.3.adoc create mode 100644 docs/man/nng_iov.5.adoc create mode 100644 docs/man/nng_ipc.7.adoc delete mode 100644 docs/man/nng_ipc.adoc create mode 100644 docs/man/nng_ipc_register.3.adoc rename docs/man/{nng_listen.adoc => nng_listen.3.adoc} (56%) create mode 100644 docs/man/nng_listener.5.adoc rename docs/man/{nng_listener_close.adoc => nng_listener_close.3.adoc} (73%) create mode 100644 docs/man/nng_listener_create.3.adoc delete mode 100644 docs/man/nng_listener_create.adoc rename docs/man/{nng_listener_getopt.adoc => nng_listener_getopt.3.adoc} (91%) rename docs/man/{nng_listener_setopt.adoc => nng_listener_setopt.3.adoc} (89%) rename docs/man/{nng_listener_start.adoc => nng_listener_start.3.adoc} (73%) create mode 100644 docs/man/nng_msg.5.adoc rename docs/man/{nng_msg_alloc.adoc => nng_msg_alloc.3.adoc} (72%) rename docs/man/{nng_msg_append.adoc => nng_msg_append.3.adoc} (73%) rename docs/man/{nng_msg_body.adoc => nng_msg_body.3.adoc} (53%) rename docs/man/{nng_msg_chop.adoc => nng_msg_chop.3.adoc} (72%) rename docs/man/{nng_msg_clear.adoc => nng_msg_clear.3.adoc} (86%) rename docs/man/{nng_msg_dup.adoc => nng_msg_dup.3.adoc} (74%) rename docs/man/{nng_msg_free.adoc => nng_msg_free.3.adoc} (83%) rename docs/man/{nng_msg_get_pipe.adoc => nng_msg_get_pipe.3.adoc} (63%) rename docs/man/{nng_msg_header.adoc => nng_msg_header.3.adoc} (66%) rename docs/man/{nng_msg_header_append.adoc => nng_msg_header_append.3.adoc} (70%) rename docs/man/{nng_msg_header_chop.adoc => nng_msg_header_chop.3.adoc} (75%) rename docs/man/{nng_msg_header_clear.adoc => nng_msg_header_clear.3.adoc} (86%) rename docs/man/{nng_msg_header_insert.adoc => nng_msg_header_insert.3.adoc} (72%) rename docs/man/{nng_msg_header_len.adoc => nng_msg_header_len.3.adoc} (84%) rename docs/man/{nng_msg_header_trim.adoc => nng_msg_header_trim.3.adoc} (74%) rename docs/man/{nng_msg_insert.adoc => nng_msg_insert.3.adoc} (58%) rename docs/man/{nng_msg_len.adoc => nng_msg_len.3.adoc} (84%) rename docs/man/{nng_msg_realloc.adoc => nng_msg_realloc.3.adoc} (61%) rename docs/man/{nng_msg_set_pipe.adoc => nng_msg_set_pipe.3.adoc} (71%) rename docs/man/{nng_msg_trim.adoc => nng_msg_trim.3.adoc} (73%) rename docs/man/{nng_options.adoc => nng_options.5.adoc} (80%) rename docs/man/{nng_pair.adoc => nng_pair.7.adoc} (59%) create mode 100644 docs/man/nng_pair_open.3.adoc create mode 100644 docs/man/nng_pipe.5.adoc create mode 100644 docs/man/nng_pipe_close.3.adoc rename docs/man/{nng_pipe_getopt.adoc => nng_pipe_getopt.3.adoc} (55%) create mode 100644 docs/man/nng_pub.7.adoc delete mode 100644 docs/man/nng_pub.adoc create mode 100644 docs/man/nng_pub_open.3.adoc rename docs/man/{nng_pull.adoc => nng_pull.7.adoc} (52%) create mode 100644 docs/man/nng_pull_open.3.adoc create mode 100644 docs/man/nng_push.7.adoc delete mode 100644 docs/man/nng_push.adoc create mode 100644 docs/man/nng_push_open.3.adoc rename docs/man/{nng_recv.adoc => nng_recv.3.adoc} (64%) create mode 100644 docs/man/nng_recv_aio.3.adoc rename docs/man/{nng_recvmsg.adoc => nng_recvmsg.3.adoc} (75%) create mode 100644 docs/man/nng_rep.7.adoc delete mode 100644 docs/man/nng_rep.adoc create mode 100644 docs/man/nng_rep_open.3.adoc rename docs/man/{nng_req.adoc => nng_req.7.adoc} (54%) create mode 100644 docs/man/nng_req_open.3.adoc create mode 100644 docs/man/nng_respondent.7.adoc delete mode 100644 docs/man/nng_respondent.adoc create mode 100644 docs/man/nng_respondent_open.3.adoc rename docs/man/{nng_send.adoc => nng_send.3.adoc} (59%) create mode 100644 docs/man/nng_send_aio.3.adoc rename docs/man/{nng_sendmsg.adoc => nng_sendmsg.3.adoc} (57%) rename docs/man/{nng_setopt.adoc => nng_setopt.3.adoc} (84%) rename docs/man/{nng_sleep_aio.adoc => nng_sleep_aio.3.adoc} (73%) rename docs/man/{nng_sockaddr.adoc => nng_sockaddr.5.adoc} (58%) create mode 100644 docs/man/nng_sockaddr_in.5.adoc create mode 100644 docs/man/nng_sockaddr_in6.5.adoc create mode 100644 docs/man/nng_sockaddr_inproc.5.adoc create mode 100644 docs/man/nng_sockaddr_ipc.5.adoc create mode 100644 docs/man/nng_sockaddr_zt.5.adoc rename docs/man/{nng_socket.adoc => nng_socket.5.adoc} (67%) rename docs/man/{nng_strerror.adoc => nng_strerror.3.adoc} (88%) rename docs/man/{nng_sub.adoc => nng_sub.7.adoc} (59%) create mode 100644 docs/man/nng_sub_open.3.adoc create mode 100644 docs/man/nng_surveyor.7.adoc delete mode 100644 docs/man/nng_surveyor.adoc create mode 100644 docs/man/nng_surveyor_open.3.adoc create mode 100644 docs/man/nng_tcp.7.adoc delete mode 100644 docs/man/nng_tcp.adoc create mode 100644 docs/man/nng_tcp_register.3.adoc rename docs/man/{nng_tls.adoc => nng_tls.7.adoc} (54%) rename docs/man/{nng_tls_config_alloc.adoc => nng_tls_config_alloc.3tls.adoc} (76%) rename docs/man/{nng_tls_config_auth_mode.adoc => nng_tls_config_auth_mode.3tls.adoc} (61%) rename docs/man/{nng_tls_config_ca_chain.adoc => nng_tls_config_ca_chain.3tls.adoc} (72%) rename docs/man/{nng_tls_config_ca_file.adoc => nng_tls_config_ca_file.3tls.adoc} (71%) rename docs/man/{nng_tls_config_cert_key_file.adoc => nng_tls_config_cert_key_file.3tls.adoc} (72%) rename docs/man/{nng_tls_config_free.adoc => nng_tls_config_free.3tls.adoc} (88%) rename docs/man/{nng_tls_config_own_cert.adoc => nng_tls_config_own_cert.3tls.adoc} (76%) rename docs/man/{nng_tls_config_server_name.adoc => nng_tls_config_server_name.3tls.adoc} (67%) create mode 100644 docs/man/nng_tls_register.3.adoc rename docs/man/{nng_url_clone.adoc => nng_url_clone.3.adoc} (75%) rename docs/man/{nng_url_free.adoc => nng_url_free.3.adoc} (85%) rename docs/man/{nng_url_parse.adoc => nng_url_parse.3.adoc} (96%) rename docs/man/{nng_version.adoc => nng_version.3.adoc} (90%) rename docs/man/{nng_ws.adoc => nng_ws.7.adoc} (56%) create mode 100644 docs/man/nng_ws_register.3.adoc create mode 100644 docs/man/nng_wss_register.3.adoc rename docs/man/{nng_zerotier.adoc => nng_zerotier.7.adoc} (64%) create mode 100644 docs/man/nng_zerotier_register.3.adoc rename docs/man/{nngcat.adoc => nngcat.1.adoc} (68%) diff --git a/docs/man/libnng.3.adoc b/docs/man/libnng.3.adoc new file mode 100644 index 000000000..ba68b17cb --- /dev/null +++ b/docs/man/libnng.3.adoc @@ -0,0 +1,319 @@ += libnng(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +libnng - nanomsg next generation library + +== SYNOPSIS + +*cc* [_flags_] _files_ *-lnng* [_libraries_] + +== DESCRIPTION + +The <> library provides a common messaging framework +intended to solve common communication problems in distributed applications. + +It provides a C language API. + +=== Common Functions + +The following common functions exist in _libnng_. + +|=== +|<>|allocate memory +|<>|free memory +|<>|return an error description +|<>|report library version +|=== + +=== Socket Functions + +The following functions operate on sockets. + +|=== +|<>|close socket +|<>|create and start dialer +|<>|get socket option +|<>|create and start listener +|<>|receive data +|<>|send data +|<>|set socket option +|=== + +=== Connection Management + +The following functions are used with either listeners, or dialers. +Listeners accept incoming connection requets, and dialers make them. + +|=== +|<>|create and start dialer +|<>|close dialer +|<>|create dialer +|<>|get dialer option +|<>|set dialer option +|<>|start dialer +|<>|create and start listener +|<>|close listener +|<>|create listener +|<>|get listener option +|<>|set listener option +|<>|start listener +|<>|close pipe +|<>|get pipe option +|=== + +=== Message Handling Functions + +Applications desiring to use the richest part of _libnng_ will want to +use the message API, where a message structure is passed between functions. +This API provides the most power support for zero-copy. + +Messages are divided into a header and body, where the body generally carries +user-payload and the header carries protocol specific header information. +Most applications will only interact with the body. + +|=== +|<>|allocate a message +|<>|append to message body +|<>|return message body +|<>|remove data from end of message body +|<>|clear message body +|<>|duplicate a message +|<>|free a message +|<>|get pipe for message +|<>|prepend to message body +|<>|return the message body length +|<>|reallocate a message +|<>|set pipe for message +|<>|remove data from start of message body +|<>|receive a message +|<>|send a message +|=== + +==== Message Header Handling + +TIP: Few applications will need these functions, as message headers are only +used to carry protocol-specific content. However, applications which use raw +mode may need to access the header of messages. + +|=== +|<>|return message header +|<>|append to message header +|<>|remove data from end of message header +|<>|clear message header +|<>|prepend to message header +|<>|return the message header length +|<>|remove data from start of message header +|=== + +=== Asynchronous Operations + +Most applications will interact with _nng_ synchronously; that is that +functions such as <> will block the calling +thread until the operation has completed. + +NOTE: Synchronous operations which send messages may return before the +message has actually been received, or even transmitted. Instead, These +functions return as soon as the message was successfully queued for +delivery. + +Asynchronous operations behave differently. These operations are +initiated by the calling thread, but control returns immediately to +the calling thread. When the operation is subsequently completed (regardless +of whether this was successful or not), then a user supplied function +("callback") is executed. + +A context structure, an <>, is allocated and +associated with each asynchronous operation. +Only a single asynchronous operation may be associated with an +`nng_aio` at any time. + +The following functions are used in the asynchronous model: + +|=== +|<>|abort asynchronous I/O operation +|<>|allocate asynchronous I/O handle +|<>|cancel asynchronous I/O operation +|<>|return number of bytes transferred +|<>|finish an asynchronous I/O operation +|<>|free asynchronous I/O handle +|<>|return input parameter +|<>|get message from an asynchronous receive +|<>|return output result +|<>|return result of asynchronous operation +|<>|set input parameter +|<>|set scatter/gather vector +|<>|set message for an asynchronous send +|<>|set output result +|<>|set asynchronous I/O timeout +|<>|stop asynchronous I/O operation +|<>|wait for asynchronous I/O operation +|<>|receive message asynchronously +|<>|send message asynchronously +|<>|sleep asynchronously +|=== + +=== Protocols + +The following functions are used to construct a socket with a specific protocol: + +|=== +|<>|open a bus socket +|<>|open a pair socket +|<>|open a pub socket +|<>|open a pull socket +|<>|open a push socket +|<>|open a rep socket +|<>|open a req socket +|<>|open a respondent socket +|<>|open a sub socket +|<>|open a surveyor socket +|=== + +=== Transports + +The following functions are used to register a transport for use. + +|=== +| <>|register inproc transport +| <>|register IPC transport +| <>|register TCP transport +| <>|register TLS transport +| <>|register WebSocket transport +| <>|register WebSocket Secure transport +| <>|register ZeroTier transport +|=== + +=== URL Object + +Common functionality is supplied for parsing and handling +universal resource locators (URLS). + +|=== +|<>|clone URL structure +|<>|free URL structure +|<>|create URL structure from string +|=== + + +=== HTTP Support + +The library may be configured with support for HTTP, and this will +be the case if WebSocket support is configured as well. +In this case, it is possible to access functionality to support the creation of +HTTP (and HTTP/S if TLS support is present) servers and clients. + +==== Common HTTP Functions + +The following functions are used to work with HTTP requests, responses, +and connections. + +|=== +|<>|close HTTP connection +|<>|read from HTTP connection +|<>|read all from HTTP connection +|<>|read HTTP request +|<>|read HTTP response +|<>|write to HTTP connection +|<>|write all to HTTP connection +|<>|write HTTP request +|<>|write HTTP response +|<>|add HTTP request header +|<>|allocate HTTP request structure +|<>|copy HTTP request body +|<>|delete HTTP request header +|<>|free HTTP request structure +|<>|return HTTP request header +|<>|return HTTP request method +|<>|return HTTP request URI +|<>|return HTTP request protocol version +|<>|set HTTP request body +|<>|set HTTP request header +|<>|set HTTP request method +|<>|set HTTP request URI +|<>|set HTTP request protocol version +|<>|add HTTP response header +|<>|allocate HTTP response structure +|<>|allocate HTTP error response +|<>|copy HTTP response body +|<>|delete HTTP response header +|<>|free HTTP response structure +|<>|set HTTP response body +|<>|return HTTP response header +|<>|return HTTP response reason +|<>|return HTTP response status +|<>|return HTTP response protocol version +|<>|set HTTP response header +|<>|set HTTP response reason +|<>|set HTTP response status +|<>|set HTTP response protocol version +|=== + +==== HTTP Client Functions + +These functions are intended for use with HTTP client applications. + +|=== +| <>|allocate HTTP client +| <>|establish HTTP client connection +| <>|free HTTP client +| <>|get HTTP client TLS configuration +| <>|set HTTP client TLS configuration +|=== + +==== HTTP Server Functions + +These functions are intended for use with HTTP server applications. + +|=== +|<>|allocate HTTP server handler +|<>|free HTTP server handler +|<>|return extra data for HTTP handler +|<>|set extra data for HTTP handler +|<>|set host for HTTP handler +|<>|set HTTP handler method +|<>|set HTTP handler to match trees +|<>|hijack HTTP server connection +|<>|add HTTP server handler +|<>|delete HTTP server handler +|<>|get HTTP server TLS configuration +|<>|get and hold HTTP server instance +|<>|release HTTP server instance +|<>|set HTTP server TLS configuration +|<>|start HTTP server +|<>|stop HTTP server +|=== + +=== TLS Configuration Objects + +The following functions are used to manipulate transport layer security +(TLS) configuration objects. + +NOTE: These functions will only be present if the library has been built +with TLS support. + +|=== +|<>|allocate TLS configuration +|<>|set authentication mode +|<>|set certificate authority chain +|<>|load certificate authority from file +|<>|load own certificate and key from file +|<>|set own certificate and key +|<>|free TLS configuration +|<>|set remote server name +|=== + + +== SEE ALSO + +<>, +<> diff --git a/docs/man/libnng.adoc b/docs/man/libnng.adoc deleted file mode 100644 index 68cbdcf4c..000000000 --- a/docs/man/libnng.adoc +++ /dev/null @@ -1,318 +0,0 @@ -= libnng(3) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -libnng - nanomsg next generation library - -== SYNOPSIS - -*cc* [_flags_] _files_ *-lnng* [_libraries_] - -== DESCRIPTION - -The <> library provides a common messaging framework -intended to solve common communication problems in distributed applications. - -It provides a C language API. - -=== Common Functions - -The following common functions exist in _libnng_. - -|=== -|<>|allocate memory -|<>|free memory -|<>|return an error description -|<>|report library version -|=== - -=== Socket Functions - -The following functions operate on sockets. - -|=== -|<>|close socket -|<>|create and start dialer -|<>|get socket option -|<>|create and start listener -|<>|receive data -|<>|send data -|<>|set socket option -|=== - -=== Connection Management - -The following functions are used with either listeners, or dialers. -Listeners accept incoming connection requets, and dialers make them. - -|=== -|<>|create and start dialer -|<>|close dialer -|<>|create dialer -|<>|get dialer option -|<>|set dialer option -|<>|start dialer -|<>|create and start listener -|<>|close listener -|<>|create listener -|<>|get listener option -|<>|set listener option -|<>|start listener -|<>|get pipe option -|=== - -=== Message Handling Functions - -Applications desiring to use the richest part of _libnng_ will want to -use the message API, where a message structure is passed between functions. -This API provides the most power support for zero-copy. - -Messages are divided into a header and body, where the body generally carries -user-payload and the header carries protocol specific header information. -Most applications will only interact with the body. - -|=== -|<>|allocate a message -|<>|append to message body -|<>|return message body -|<>|remove data from end of message body -|<>|clear message body -|<>|duplicate a message -|<>|free a message -|<>|get pipe for message -|<>|prepend to message body -|<>|return the message body length -|<>|reallocate a message -|<>|set pipe for message -|<>|remove data from start of message body -|<>|receive a message -|<>|send a message -|=== - -==== Message Header Handling - -TIP: Few applications will need these functions, as message headers are only -used to carry protocol-specific content. However, applications which use raw -mode may need to access the header of messages. - -|=== -|<>|return message header -|<>|append to message header -|<>|remove data from end of message header -|<>|clear message header -|<>|prepend to message header -|<>|return the message header length -|<>|remove data from start of message header -|=== - -=== Asynchronous Operations - -Most applications will interact with _nng_ synchronously; that is that -functions such as <> will block the calling -thread until the operation has completed. - -NOTE: Synchronous operations which send messages may return before the -message has actually been received, or even transmitted. Instead, These -functions return as soon as the message was successfully queued for -delivery. - -Asynchronous operations behave differently. These operations are -initiated by the calling thread, but control returns immediately to -the calling thread. When the operation is subsequently completed (regardless -of whether this was successful or not), then a user supplied function -("callback") is executed. - -A context structure, called an _aio_, is allocated and associated for -each asynchronous operation. Only a single asynchronous operation may -be associated with an _aio_ at any time. - -The following functions are used in the asynchronous model: - -|=== -|<>|abort asynchronous I/O operation -|<>|allocate asynchronous I/O handle -|<>|cancel asynchronous I/O operation -|<>|return number of bytes transferred -|<>|finish an asynchronous I/O operation -|<>|free asynchronous I/O handle -|<>|return input parameter -|<>|get message from an asynchronous receive -|<>|return output result -|<>|return result of asynchronous operation -|<>|set input parameter -|<>|set scatter/gather vector -|<>|set message for an asynchronous send -|<>|set output result -|<>|set asynchronous I/O timeout -|<>|stop asynchronous I/O operation -|<>|wait for asynchronous I/O operation -|<>|receive message asynchronously -|<>|send message asynchronously -|<>|sleep asynchronously -|=== - -=== Protocols - -The following functions are used to construct a socket with a specific -protocol: - -|=== -|<>|open a bus socket -|<>|open a pair socket -|<>|open a pub socket -|<>|open a pull socket -|<>|open a push socket -|<>|open a rep socket -|<>|open a req socket -|<>|open a respondent socket -|<>|open a sub socket -|<>|open a surveyor socket -|=== - -=== Transports - -The following functions are used to register a transport for use. - -|=== -| <>|register inproc transport -| <>|register IPC transport -| <>|register TCP transport -| <>|register TLS transport -| <>|register WebSocket transport -| <>|register WebSocket Secure transport -| <>|register ZeroTier transport -|=== - -=== URL Object - -Common functionality is supplied for parsing and handling -universal resource locators (URLS). - -|=== -|<>|clone URL structure -|<>|free URL structure -|<>|create URL structure from string -|=== - - -=== HTTP Support - -The library may be configured with support for HTTP, and this will -be the case if WebSocket support is configured as well. In this case, -it is possible to access functionality to support the creation of -HTTP (and HTTP/S if TLS support is present) servers and clients. - -==== Common HTTP Functions - -The following functions are used to work with HTTP requests, responses, -and connections. - -|=== -|<>|close HTTP connection -|<>|read from HTTP connection -|<>|read all from HTTP connection -|<>|read HTTP request -|<>|read HTTP response -|<>|write to HTTP connection -|<>|write all to HTTP connection -|<>|write HTTP request -|<>|write HTTP response -|<>|add HTTP request header -|<>|allocate HTTP request structure -|<>|copy HTTP request body -|<>|delete HTTP request header -|<>|free HTTP request structure -|<>|return HTTP request header -|<>|return HTTP request method -|<>|return HTTP request URI -|<>|return HTTP request protocol version -|<>|set HTTP request body -|<>|set HTTP request header -|<>|set HTTP request method -|<>|set HTTP request URI -|<>|set HTTP request protocol version -|<>|add HTTP response header -|<>|allocate HTTP response structure -|<>|allocate HTTP error response -|<>|copy HTTP response body -|<>|delete HTTP response header -|<>|free HTTP response structure -|<>|set HTTP response body -|<>|return HTTP response header -|<>|return HTTP response reason -|<>|return HTTP response status -|<>|return HTTP response protocol version -|<>|set HTTP response header -|<>|set HTTP response reason -|<>|set HTTP response status -|<>|set HTTP response protocol version -|=== - -==== HTTP Client Functions - -These functions are intended for use with HTTP client applications. - -|=== -| <>|allocate HTTP client -| <>|establish HTTP client connection -| <>|free HTTP client -| <>|get HTTP client TLS configuration -| <>|set HTTP client TLS configuration -|=== - -==== HTTP Server Functions - -These functions are intended for use with HTTP server applications. - -|=== -|<>|allocate HTTP server handler -|<>|free HTTP server handler -|<>|return extra data for HTTP handler -|<>|set extra data for HTTP handler -|<>|set host for HTTP handler -|<>|set HTTP handler method -|<>|set HTTP handler to match trees -|<>|hijack HTTP server connection -|<>|add HTTP server handler -|<>|delete HTTP server handler -|<>|get HTTP server TLS configuration -|<>|get and hold HTTP server instance -|<>|release HTTP server instance -|<>|set HTTP server TLS configuration -|<>|start HTTP server -|<>|stop HTTP server -|=== - -=== TLS Configuration Objects - -The following functions are used to manipulate transport layer security -(TLS) configuration objects. - -NOTE: These functions will only be present if the library has been built -with TLS support. - -|=== -|<>|allocate TLS configuration -|<>|set authentication mode -|<>|set certificate authority chain -|<>|load certificate authority from file -|<>|load own certificate and key from file -|<>|set own certificate and key -|<>|free TLS configuration -|<>|set remote server name -|=== - - -== SEE ALSO - -<>, -<> diff --git a/docs/man/man1.desc b/docs/man/man1.desc new file mode 100644 index 000000000..a5122517b --- /dev/null +++ b/docs/man/man1.desc @@ -0,0 +1,2 @@ +This section documents utilities and programs that are included +with the distribution. diff --git a/docs/man/man1.sect b/docs/man/man1.sect new file mode 100644 index 000000000..026bbf3b6 --- /dev/null +++ b/docs/man/man1.sect @@ -0,0 +1 @@ +Commands and Utilities diff --git a/docs/man/man3.desc b/docs/man/man3.desc new file mode 100644 index 000000000..5a0aa91c0 --- /dev/null +++ b/docs/man/man3.desc @@ -0,0 +1,2 @@ +This section documents core libary functions that are +callable by applications. diff --git a/docs/man/man3.sect b/docs/man/man3.sect new file mode 100644 index 000000000..f711bdc52 --- /dev/null +++ b/docs/man/man3.sect @@ -0,0 +1 @@ +Library Functions diff --git a/docs/man/man3compat.desc b/docs/man/man3compat.desc new file mode 100644 index 000000000..f9075ddd1 --- /dev/null +++ b/docs/man/man3compat.desc @@ -0,0 +1 @@ +This section documents the _nanomsg_ 1.0 libary compatible functions. diff --git a/docs/man/man3compat.sect b/docs/man/man3compat.sect new file mode 100644 index 000000000..75a97a08c --- /dev/null +++ b/docs/man/man3compat.sect @@ -0,0 +1 @@ +Compatible Library Functions diff --git a/docs/man/man3http.desc b/docs/man/man3http.desc new file mode 100644 index 000000000..18ee52d12 --- /dev/null +++ b/docs/man/man3http.desc @@ -0,0 +1,2 @@ +This section documents supplemental HTTP support functions +that are available. diff --git a/docs/man/man3http.sect b/docs/man/man3http.sect new file mode 100644 index 000000000..3ae1b8134 --- /dev/null +++ b/docs/man/man3http.sect @@ -0,0 +1 @@ +Supplemental HTTP Functions diff --git a/docs/man/man3tls.desc b/docs/man/man3tls.desc new file mode 100644 index 000000000..a9cf7b794 --- /dev/null +++ b/docs/man/man3tls.desc @@ -0,0 +1 @@ +This section documents supplemental TLS functions that are available. diff --git a/docs/man/man3tls.sect b/docs/man/man3tls.sect new file mode 100644 index 000000000..6f789ccfa --- /dev/null +++ b/docs/man/man3tls.sect @@ -0,0 +1 @@ +Supplemental TLS Functions diff --git a/docs/man/man5.desc b/docs/man/man5.desc new file mode 100644 index 000000000..3ed7d2594 --- /dev/null +++ b/docs/man/man5.desc @@ -0,0 +1 @@ +This section documents core macros and types that are available. diff --git a/docs/man/man5.sect b/docs/man/man5.sect new file mode 100644 index 000000000..a3d77c997 --- /dev/null +++ b/docs/man/man5.sect @@ -0,0 +1 @@ +Macros and Types diff --git a/docs/man/man7.desc b/docs/man/man7.desc new file mode 100644 index 000000000..0596209bf --- /dev/null +++ b/docs/man/man7.desc @@ -0,0 +1,2 @@ +This sections documents various protocols and transports that are +available in the distribution. diff --git a/docs/man/man7.sect b/docs/man/man7.sect new file mode 100644 index 000000000..b82263dfc --- /dev/null +++ b/docs/man/man7.sect @@ -0,0 +1 @@ +Protocols and Transports diff --git a/docs/man/nng.adoc b/docs/man/nng.7.adoc similarity index 80% rename from docs/man/nng.adoc rename to docs/man/nng.7.adoc index 2d0f6567e..7b145a541 100644 --- a/docs/man/nng.adoc +++ b/docs/man/nng.7.adoc @@ -51,25 +51,25 @@ other languages please check the http://nanomsg.org/[website]. == Protocols -* <> - Bus protocol -* <> - Pair protocol -* <> - Publisher side of publish/subscribe protocol -* <> - Pull side of pipeline protocol -* <> - Push side of pipeline protocol -* <> - Subscriber side of publish/subscribe protocol -* <> - Reply side of request/reply protocol -* <> - Request side of request/reply protocol -* <> - Respondent side of survey protocol -* <> - Surveyor side of survey protocol +* <> - Bus protocol +* <> - Pair protocol +* <> - Publisher side of publish/subscribe protocol +* <> - Pull side of pipeline protocol +* <> - Push side of pipeline protocol +* <> - Subscriber side of publish/subscribe protocol +* <> - Reply side of request/reply protocol +* <> - Request side of request/reply protocol +* <> - Respondent side of survey protocol +* <> - Surveyor side of survey protocol == Transports -* <> - Intra-process transport -* <> - Inter-process transport -* <> - TLSv1.2 over TCP transport -* <> - TCP (and TCPv6) transport -* <> - WebSocket transport -* <> - ZeroTier transport +* <> - Intra-process transport +* <> - Inter-process transport +* <> - TLSv1.2 over TCP transport +* <> - TCP (and TCPv6) transport +* <> - WebSocket transport +* <> - ZeroTier transport == Conceptual Overview @@ -79,14 +79,14 @@ one _nng_ protocol. Each socket can be used to send and receive messages (if the protocol) supports it, and implements the appropriate protocol semantics. For -example, <> sockets automatically filter incoming +example, <> sockets automatically filter incoming messages to discard those for topics that have not been subscribed. _nng_ sockets are message oriented, so that messages are either delivered wholly, or not at all. Partial delivery is not possible. Furthermore, _nng_ does not provide any other delivery or ordering guarantees; messages may be dropped or reordered. (Some protocols, such as -<> may offer stronger guarantees by +<> may offer stronger guarantees by performing their own retry and validation schemes.) Each socket can have zero, one, or many "endpoints", which are either @@ -115,11 +115,13 @@ other than in a few specific circumstances. === URLs -The _nng_ library uses universal resource locators (URLs) +(((URL))) +The _nng_ library uses ((universal resource locators)) (URLs) following the format specified in https://tools.ietf.org/html/rfc3986[RFC 3986], including some schemes that are unique to SP. +(((URL, canonicalized))) The URLs used in _nng_ are canonicalized as follows, mostly in accordance with https://tools.ietf.org/html/rfc3986#section-6.2.2[RFC 3986 6.2.2]: @@ -146,9 +148,9 @@ applications, without violating RFC 3986 itself. == API -The library API is documented at <>. +The library API is documented at <>. == SEE ALSO -<>, -<> +<>, +<> diff --git a/docs/man/nng_aio.5.adoc b/docs/man/nng_aio.5.adoc new file mode 100644 index 000000000..4353652d9 --- /dev/null +++ b/docs/man/nng_aio.5.adoc @@ -0,0 +1,69 @@ += nng_aio(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_aio - asynchronous I/O handle + +== SYNOPSIS + +[source, c] +---- +#include + +typedef struct nng_aio nng_aio; +---- + +== DESCRIPTION + +An `nng_aio`(((aio))) is an opaque structure used in conjuction with +((asynchronous I/O)) operations. +Every asynchronous operation uses one of these structures, each of which +can only be used with a single operation at a time. + +Asynchronous operations are performed without blocking calling application +threads. +Instead the application registers a "`callback`" function to be executed +when the operation is complete (whether successfully or not). +This callback will be executed exactly once. + +The asynchronous I/O framework in _nng_ also supports cancellation of +operations that are already in progress +(see <>), as well setting a maximum +timeout for them to complete within +(see <>). + +It is also possible to initiate an asynchronous operation, and wait for it to +complete using <>. + +These structures are created using the <>, +and destroyed using <>. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_abort.adoc b/docs/man/nng_aio_abort.3.adoc similarity index 75% rename from docs/man/nng_aio_abort.adoc rename to docs/man/nng_aio_abort.3.adoc index 51e1533de..4216343e2 100644 --- a/docs/man/nng_aio_abort.adoc +++ b/docs/man/nng_aio_abort.3.adoc @@ -16,18 +16,19 @@ nng_aio_abort - abort asynchronous I/O operation == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_abort(nng_aio *aio, int err); ------------ +---- == DESCRIPTION The `nng_aio_abort()` function aborts an operation previously started -with the handle _aio_. If the operation is aborted, then the callback +with the handle _aio_. +If the operation is aborted, then the callback for the handle will be called, and the function -<> will return the error _err_. +<> will return the error _err_. This function does not wait for the operation to be fully aborted, but returns immediately. @@ -46,7 +47,8 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_alloc.3.adoc b/docs/man/nng_aio_alloc.3.adoc new file mode 100644 index 000000000..71521f470 --- /dev/null +++ b/docs/man/nng_aio_alloc.3.adoc @@ -0,0 +1,80 @@ += nng_aio_alloc(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_aio_alloc - allocate asynchronous I/O handle + +== SYNOPSIS + +[source, c] +---- +#include + +int nng_aio_alloc(nng_aio **aiop, void (*callb)(void *), void *arg); +---- + +== DESCRIPTION + +The `nng_aio_alloc()` function allocates a handle for ((asynchronous I/O)) +operations, and stores a pointer to it in __aiop__. +The handle is initialized with a completion ((callback)) of _callb_, +which will be executed when an associated asynchronous operation finishes. +It will be called with the argument _arg_. + +NOTE: The callback _callb_ must not perform any blocking operations, and +must complete it's execution quickly. If _callb_ does block, this can +lead ultimately to an apparent "hang" or deadlock in the application. + +Asynchronous I/O operations all take an <> +handle such as allocated by this function. +Such operations are usually started by a function that returns immediately. +The operation is then run asynchronously, and completes sometime later. +When that operation is complete, the callback supplied here is called, +and that callback is able to determine the result of the operation using +<>, +<>, +and <>. + +It is possible to wait synchronously for an otherwise asynchronous operation +by using the function <>. +In that case, it is permissible for _callb_ and _arg_ to both be `NULL`. +Note that if these are `NULL`, then it will not be possible to determine when the +operation is complete except by calling the aforementioned +<>. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient free memory to perform the operation. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_alloc.adoc b/docs/man/nng_aio_alloc.adoc deleted file mode 100644 index 2ca958292..000000000 --- a/docs/man/nng_aio_alloc.adoc +++ /dev/null @@ -1,77 +0,0 @@ -= nng_aio_alloc(3) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_aio_alloc - allocate asynchronous I/O handle - -== SYNOPSIS - -[source, c] ------------ -#include - -int nng_aio_alloc(nng_aio **aiop, void (*callb)(void *), void *arg); ------------ - -== DESCRIPTION - -The `nng_aio_alloc()` function allocates a handle for asynchronous I/O -operations, and stores a pointer to it in __aiop__. The handle is initialized -with a completion callback of _callb_, which will be executed when an -associated asynchronous operation finishes. It will be called with the -argument _arg_. - -NOTE: The callback _callb_ must not perform any blocking operations, and -must complete it's execution quickly. If _callb_ does block, this can -lead ultimately to an apparent "hang" or deadlock in the application. - -Asynchronous I/O operations all take an _aio_ handle such as allocated by -this function. Such operations are usually started by a function that returns -immediately. The operation is then run asynchronously, and completes sometime -later. When that operation is complete, the callback supplied here is called, -and that callback is able to determine the result of the operation using -<>, <>, -and <>. - -It is possible to wait synchronously for an otherwise asynchronous operation -by using the function <>. In that case, -it is permissible for _callb_ and _arg_ to both be `NULL`. Note that if -these are `NULL`, then it will not be possible to determine when the -operation is complete except by calling the aforementioned -<>. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -`NNG_ENOMEM`:: Insufficient free memory to perform the operation. - -== SEE ALSO - -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> diff --git a/docs/man/nng_aio_cancel.adoc b/docs/man/nng_aio_cancel.3.adoc similarity index 70% rename from docs/man/nng_aio_cancel.adoc rename to docs/man/nng_aio_cancel.3.adoc index 98eb682a2..77573bac3 100644 --- a/docs/man/nng_aio_cancel.adoc +++ b/docs/man/nng_aio_cancel.3.adoc @@ -25,9 +25,10 @@ void nng_aio_cancel(nng_aio *aio); == DESCRIPTION The `nng_aio_cancel()` function aborts an operation previously started -with the handle _aio_. If the operation is aborted, then the callback +with the handle _aio_. +If the operation is aborted, then the callback for the handle will be called, and the function -<> will return the error `NNG_ECANCELED`. +<> will return the error `NNG_ECANCELED`. This function does not wait for the operation to be fully aborted, but returns immediately. @@ -36,8 +37,8 @@ If no operation is currently in progress (either because it has already finished, or no operation has been started yet), then this function has no effect. -NOTE: This function is the same as calling <> -with the error `NNG_ECANCELED`. +NOTE: This function is the same as calling +<> with the error `NNG_ECANCELED`. == RETURN VALUES @@ -49,7 +50,8 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_count.adoc b/docs/man/nng_aio_count.3.adoc similarity index 70% rename from docs/man/nng_aio_count.adoc rename to docs/man/nng_aio_count.3.adoc index 6ea42bf91..dc467abd4 100644 --- a/docs/man/nng_aio_count.adoc +++ b/docs/man/nng_aio_count.3.adoc @@ -16,11 +16,11 @@ nng_aio_count - return number of bytes transferred == SYNOPSIS [source, c] ------------ +---- #include size_t nng_aio_count(nng_aio *aio); ------------ +---- == DESCRIPTION @@ -33,12 +33,13 @@ transfer user data (they may transfer protocol data though) -- in this case this function will generally return zero. This function is most useful when used with operations that make use of -of a scatter/gather vector (set by <>). +of a scatter/gather vector (set by <>). NOTE: The return value from this function is undefined if the operation -has not completed yet. Either call this from the handle's completion -callback, or after waiting for the operation to complete with -<>. +has not completed yet. +Either call this from the handle's completion callback, +or after waiting for the operation to complete with +<>. == RETURN VALUES @@ -50,9 +51,10 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_finish.adoc b/docs/man/nng_aio_finish.3.adoc similarity index 56% rename from docs/man/nng_aio_finish.adoc rename to docs/man/nng_aio_finish.3.adoc index 42c519703..9d03d8597 100644 --- a/docs/man/nng_aio_finish.adoc +++ b/docs/man/nng_aio_finish.3.adoc @@ -16,26 +16,28 @@ nng_aio_finish - finish asynchronous I/O operation == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_finish(nng_aio *aio, int err); ------------ +---- == DESCRIPTION The `nng_aio_finish()` function marks operation associated with _aio_ as -complete, with the status _err_. This will be the result returned by -<>. +complete, with the status _err_. +This will be the result returned by +<>. This function causes the callback associated with the _aio_ to called. -WARNING: It is mandatory that operation "providers" call this function -*EXACTLY ONCE* when they are finished with the operation. After calling this -function they *MUST NOT* perform any further accesses the _aio_. +IMPORTANT: It is mandatory that operation "`providers`" call this function +*EXACTLY ONCE* when they are finished with the operation. +After calling this function they *MUST NOT* perform any further accesses +to the _aio_. -WARNING: This function is only for I/O providers (those actually performing -the operation such as HTTP handler function or a transport provider); ordinary +NOTE: This function is only for I/O providers (those actually performing +the operation such as HTTP handler functions or transport providers); ordinary users of the _aio_ should not have any need for this function. == RETURN VALUES @@ -48,7 +50,8 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_free.adoc b/docs/man/nng_aio_free.3.adoc similarity index 81% rename from docs/man/nng_aio_free.adoc rename to docs/man/nng_aio_free.3.adoc index 20ece8ae5..19a371985 100644 --- a/docs/man/nng_aio_free.adoc +++ b/docs/man/nng_aio_free.3.adoc @@ -16,11 +16,11 @@ nng_aio_free - free asynchronous I/O handle == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_free(nng_aio *aio); ------------ +---- == DESCRIPTION @@ -28,7 +28,7 @@ The `nng_aio_free()` function frees an allocated asynchronous I/O handle. If any operation is in progress, the operation is canceled, and the caller is blocked until the operation is completely canceled, to ensure that it is safe to deallocate the handle and any associated resources. -(This is done by implicitly calling <>.) +(This is done by implicitly calling <>.) == RETURN VALUES @@ -40,6 +40,7 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_get_input.adoc b/docs/man/nng_aio_get_input.3.adoc similarity index 65% rename from docs/man/nng_aio_get_input.adoc rename to docs/man/nng_aio_get_input.3.adoc index 73b0acd28..e0e0d5457 100644 --- a/docs/man/nng_aio_get_input.adoc +++ b/docs/man/nng_aio_get_input.3.adoc @@ -11,26 +11,27 @@ == NAME -nng_aio_set_input - return input parameter +nng_aio_get_input - return input parameter == SYNOPSIS [source, c] ------------ +---- #include void *nng_aio_get_input(nng_aio *aio, unsigned int index); ------------ +---- == DESCRIPTION The `nng_aio_get_input()` function returns the value of the input parameter previously set at _index_ on _aio_ with the -<> function. +<> function. The valid values of _index_ range from zero (0) to three (3), as no operation -currently defined can accept more than four parameters. (This limit could -increase in the future.) If the index supplied is outside of this range, +currently defined can accept more than four parameters. +(This limit could increase in the future.) +If the index supplied is outside of this range, or of the input parameter was not previously set, then `NULL` is returned. == RETURN VALUES @@ -43,8 +44,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_get_msg.3.adoc b/docs/man/nng_aio_get_msg.3.adoc new file mode 100644 index 000000000..4ae1c38bb --- /dev/null +++ b/docs/man/nng_aio_get_msg.3.adoc @@ -0,0 +1,48 @@ += nng_aio_get_msg(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_aio_get_msg - get message from asynchronous receive + +== SYNOPSIS + +[source, c] +---- +#include + +nng_msg *nng_aio_get_msg(nng_aio *aio); +---- + +== DESCRIPTION + +The `nng_aio_get_msg()` function gets any message stored in _aio_ as +either a result of a successful receive +(see <>) +or that was previously stored with <>. + +IMPORTANT: The `nng_aio` must not have an operation in progress. + +== RETURN VALUES + +None. + +== ERRORS + +None. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_get_output.adoc b/docs/man/nng_aio_get_output.3.adoc similarity index 79% rename from docs/man/nng_aio_get_output.adoc rename to docs/man/nng_aio_get_output.3.adoc index a362e0ae5..b829def38 100644 --- a/docs/man/nng_aio_get_output.adoc +++ b/docs/man/nng_aio_get_output.3.adoc @@ -16,11 +16,11 @@ nng_aio_get_output - return output result == SYNOPSIS [source, c] ------------ +---- #include void *nng_aio_get_output(nng_aio *aio, unsigned int index); ------------ +---- == DESCRIPTION @@ -33,7 +33,7 @@ operations. NOTE: If the _index_ does not correspond to a defined output for the operation, or the operation did not succeed, then the return value will be `NULL`. -CAUTION: It is an error to call this function while the _aio_ is currently +IMPORTANT: It is an error to call this function while the _aio_ is currently in use by an active asynchronous operation, or if no operation has been performed using the _aio_ yet. @@ -47,8 +47,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_result.adoc b/docs/man/nng_aio_result.3.adoc similarity index 72% rename from docs/man/nng_aio_result.adoc rename to docs/man/nng_aio_result.3.adoc index 1b55dc0ee..38208d77d 100644 --- a/docs/man/nng_aio_result.adoc +++ b/docs/man/nng_aio_result.3.adoc @@ -16,24 +16,24 @@ nng_aio_result - return result of asynchronous operation == SYNOPSIS [source, c] ------------ +---- #include int nng_aio_wait(nng_aio *aio); ------------ - +---- == DESCRIPTION The `nng_aio_result()` returns the result of the operation associated with the handle _aio_. -If the operation was successful, then 0 is returned. Otherwise a non-zero -error code is returned. +If the operation was successful, then 0 is returned. +Otherwise a non-zero error code is returned. NOTE: The return value from this function is undefined if the operation -has not completed yet. Either call this from the handle's completion +has not completed yet. +Either call this from the handle's completion callback, or after waiting for the operation to complete with -<>. +<>. == RETURN VALUES @@ -49,8 +49,9 @@ Various other return values are possible dependending on the operation. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_set_input.adoc b/docs/man/nng_aio_set_input.3.adoc similarity index 67% rename from docs/man/nng_aio_set_input.adoc rename to docs/man/nng_aio_set_input.3.adoc index 3a240c6a2..dd921d52a 100644 --- a/docs/man/nng_aio_set_input.adoc +++ b/docs/man/nng_aio_set_input.3.adoc @@ -16,11 +16,11 @@ nng_aio_set_input - set input parameter == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_set_input(nng_aio *aio, unsigned int index, void *param); ------------ +---- == DESCRIPTION @@ -32,18 +32,17 @@ operations; the caller must supply appropriate inputs for the operation to be performed. The valid values of _index_ range from zero (0) to three (3), as no operation -currently defined can accept more than four parameters. (This limit could -increase in the future.) +currently defined can accept more than four parameters. +(This limit could increase in the future.) NOTE: If the _index_ does not correspond to a defined input for the operation, -then this function will have no effect. Note that attempts to set -parameters with an _index_ greater than three (3) will simply be ignored. +then this function will have no effect. -CAUTION: It is an error to call this function while the _aio_ is currently +IMPORTANT: It is an error to call this function while the _aio_ is currently in use by an active asynchronous operation. An input parameter set with this function may be retrieved later with -the <> function. +the <> function. == RETURN VALUES @@ -55,8 +54,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_set_iov.adoc b/docs/man/nng_aio_set_iov.3.adoc similarity index 75% rename from docs/man/nng_aio_set_iov.adoc rename to docs/man/nng_aio_set_iov.3.adoc index d5991ed61..b896f5de0 100644 --- a/docs/man/nng_aio_set_iov.adoc +++ b/docs/man/nng_aio_set_iov.3.adoc @@ -16,19 +16,19 @@ nng_aio_set_iov - set scatter/gather vector == SYNOPSIS [source, c] ------------ +---- #include int nng_aio_set_iov(nng_aio *aio, unsigned int niov, nng_iov *iov); ------------ +---- == DESCRIPTION -The `nng_aio_set_iov()` function sets a scatter/gather vector _iov_ on the +The `nng_aio_set_iov()` function sets a ((scatter/gather)) vector _iov_ on the handle _aio_. -The _iov_ is a pointer to an array of _niov_ `nng_iov` structures, which have -the following definition: +The _iov_ is a pointer to an array of _niov_ <> +structures, which have the following definition: [source, c] ---- @@ -50,7 +50,8 @@ More than four (4) `nng_iov` members may be supplied, but this may require heap allocations, and so the operation may fail with `NNG_ENOMEM`. Additionally, not every operation can support longer vectors; the actual limit is determined by the system, but is generally at least -sixteen (16). Furthermore, values for _niov_ larger than sixty-four (64) will +sixteen (16). +Furthermore, values for _niov_ larger than sixty-four (64) will generally result in `NNG_EINVAL`. == RETURN VALUES @@ -64,8 +65,10 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_set_msg.3.adoc b/docs/man/nng_aio_set_msg.3.adoc new file mode 100644 index 000000000..8f3c594fa --- /dev/null +++ b/docs/man/nng_aio_set_msg.3.adoc @@ -0,0 +1,46 @@ += nng_aio_set_msg(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_aio_set_msg - set message for asynchronous send + +== SYNOPSIS + +[source, c] +---- +#include + +void nng_aio_set_msg(nng_aio *aio, nng_msg *msg); +---- + +== DESCRIPTION + +The `nng_aio_set_msg()` function sets the message that will be used +for an asynchronous send operation (see <>). + +IMPORTANT: The `nng_aio` must not have an operation in progress. + +== RETURN VALUES + +None. + +== ERRORS + +None. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_set_output.adoc b/docs/man/nng_aio_set_output.3.adoc similarity index 76% rename from docs/man/nng_aio_set_output.adoc rename to docs/man/nng_aio_set_output.3.adoc index 4c3d4a210..8eef410a5 100644 --- a/docs/man/nng_aio_set_output.adoc +++ b/docs/man/nng_aio_set_output.3.adoc @@ -16,11 +16,11 @@ nng_aio_set_output - set output result == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_set_output(nng_aio *aio, unsigned int index, void *result); ------------ +---- == DESCRIPTION @@ -32,14 +32,14 @@ operations; the operation must supply appropriate output results when the operation completes successfully. The valid values of _index_ range from zero (0) to three (3), as no operation -currently defined can return more than four results. (This limit could -increase in the future.) +currently defined can return more than four results. +(This limit could increase in the future.) NOTE: Note that attempts to set results with an _index_ greater than three (3) will be ignored. An output result set with this function may be retrieved later with -the <> function. +the <> function. == RETURN VALUES @@ -51,8 +51,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_set_timeout.adoc b/docs/man/nng_aio_set_timeout.3.adoc similarity index 65% rename from docs/man/nng_aio_set_timeout.adoc rename to docs/man/nng_aio_set_timeout.3.adoc index ff1244d57..29321504e 100644 --- a/docs/man/nng_aio_set_timeout.adoc +++ b/docs/man/nng_aio_set_timeout.3.adoc @@ -16,24 +16,26 @@ nng_aio_set_timeout - set asynchronous I/O timeout == SYNOPSIS [source, c] ------------ +---- #include typedef int nng_duration; void nng_aio_set_timeout(nng_aio *aio, nng_duration timeout); ------------ +---- == DESCRIPTION -The `nng_aio_set_timeout()` function sets a _timeout_ for the asynchronous -operation associated with _aio_. This causes a timer to be started when the operation is actually -started. If the timer expires before the operation is completed, then it is -aborted with an error of `NNG_ETIMEDOUT`. The _timeout_ is specified as a -relative number of milliseconds. +The `nng_aio_set_timeout()` function sets a _timeout_(((timeout))) +for the asynchronous operation associated with _aio_. +This causes a timer to be started when the operation is actually started. +If the timer expires before the operation is completed, then it is +aborted with an error of `NNG_ETIMEDOUT`. +The _timeout_ is specified as a relative number of milliseconds. If the timeout is `NNG_DURATION_INFINITE`, then no timeout is used. If the timeout is `NNG_DURATION_DEFAULT`, then a "default" or socket-specific -timeout is used. (This is frequently the same as `NNG_DURATION_INFINITE`.) +timeout is used. +(This is frequently the same as `NNG_DURATION_INFINITE`.) TIP: As most operations involve some context switching, it is usually a good idea to allow at least a few tens of milliseconds before timing them out -- @@ -54,7 +56,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_stop.adoc b/docs/man/nng_aio_stop.3.adoc similarity index 70% rename from docs/man/nng_aio_stop.adoc rename to docs/man/nng_aio_stop.3.adoc index ae5c5bda2..5e65b8f7c 100644 --- a/docs/man/nng_aio_stop.adoc +++ b/docs/man/nng_aio_stop.3.adoc @@ -16,11 +16,11 @@ nng_aio_stop - stop asynchronous I/O operation == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_stop(nng_aio *aio); ------------ +---- == DESCRIPTION @@ -28,13 +28,13 @@ The `nng_aio_stop()` function stops the asynchronous I/O operation associated with _aio_ by aborting with `NNG_ECANCELED`, and then waits for it to complete or to be completely aborted. -This is logically the equivalent of <> -followed by <>, except that the asynchronous +This is logically the equivalent of <> +followed by <>, except that the asynchronous I/O handle may not be used for any further operations. TIP: When multiple asynchronous I/O handles are in use and need to be shut down, it is safest to stop all of them, before deallocating any of -this with <>, particularly if the callbacks +this with <>, particularly if the callbacks might attempt to reschedule additional operations. == RETURN VALUES @@ -47,8 +47,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_aio_wait.adoc b/docs/man/nng_aio_wait.3.adoc similarity index 81% rename from docs/man/nng_aio_wait.adoc rename to docs/man/nng_aio_wait.3.adoc index fb0dad870..775ddfc91 100644 --- a/docs/man/nng_aio_wait.adoc +++ b/docs/man/nng_aio_wait.3.adoc @@ -16,16 +16,17 @@ nng_aio_wait - wait for asynchronous I/O operation == SYNOPSIS [source, c] ------------ +---- #include void nng_aio_wait(nng_aio *aio); ------------ +---- == DESCRIPTION The `nng_aio_wait()` function waits for an asynchronous I/O operation -to complete. If the operation has not been started, or has already +to complete. +If the operation has not been started, or has already completed, then it returns immediately. If the a callback was set with _aio_ when it was allocated, then this @@ -41,6 +42,7 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_alloc.adoc b/docs/man/nng_alloc.3.adoc similarity index 78% rename from docs/man/nng_alloc.adoc rename to docs/man/nng_alloc.3.adoc index af81aff91..7d7adf077 100644 --- a/docs/man/nng_alloc.adoc +++ b/docs/man/nng_alloc.3.adoc @@ -16,21 +16,22 @@ nng_alloc - allocate memory == SYNOPSIS [source, c] ------------ +---- #include void *nng_alloc(size_t size); ------------ +---- == DESCRIPTION The `nng_alloc()` function allocates a contiguous memory region of -at least _size_ bytes. The memory will be 64-bit aligned. +at least _size_ bytes. +The memory will be 64-bit aligned. The returned memory can be used to hold message buffers, in which -case it can be directly passed to <> using +case it can be directly passed to <> using the flag `NNG_FLAG_ALLOC`. Alternatively, it can be freed when no -longer needed using <>. +longer needed using <>. WARNING: Do not use the system `free()` function to release this memory. On some platforms this may work, but it is not guaranteed and may lead @@ -46,7 +47,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_bus.7.adoc b/docs/man/nng_bus.7.adoc new file mode 100644 index 000000000..a05a9d04a --- /dev/null +++ b/docs/man/nng_bus.7.adoc @@ -0,0 +1,74 @@ += nng_bus(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_bus - bus protocol + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_bus0_open(nng_socket *s); +---- + +== DESCRIPTION + +(((protocol, _bus_))) +The ((_bus_ protocol)) provides for building mesh networks where +every peer is connected to every other peer. +In this protocol, each message sent by a node is sent to every one of +its directly connected peers. + +TIP: Messages are only sent to directly connected peers. +This means that in the event that a peer is connected indirectly, it will not +receive messages. +When using this protocol to build mesh networks, it +is therefore important that a _fully-connected_ mesh network be constructed. + +All message delivery in this pattern is ((best-effort)), which means that +peers may not receive messages. +Furthermore, delivery may occur to some, +all, or none of the directly connected peers. +(Messages are not delivered when peer nodes are unable to receive.) +Hence, send operations will never block; instead if the +message cannot be delivered for any reason it is discarded. + +TIP: In order to minimize the likelihood of message loss, this protocol +should not be used for high throughput communications. +Furthermore, the more traffic _in aggregate_ that occurs across the topology, +the more likely that message loss is to occur. + +=== Socket Operations + +The <> call creates a bus socket. +This socket may be used to send and receive messages. +Sending messages will attempt to deliver to each directly connected peer. + +=== Protocol Versions + +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) + +=== Protocol Options + +The _bus_ protocol has no protocol-specific options. + +=== Protocol Headers + +The _bus_ protocol has no protocol-specific headers. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_bus.adoc b/docs/man/nng_bus.adoc deleted file mode 100644 index 18ba46647..000000000 --- a/docs/man/nng_bus.adoc +++ /dev/null @@ -1,71 +0,0 @@ -= nng_bus(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_bus - bus protocol - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_bus0_open(nng_socket *s); ----------- - -== DESCRIPTION - -The _nng_bus_ protocol provides for building mesh networks where -every peer is connected to every other peer. In this protocol, -each message sent by a node is sent to every one of its directly -connected peers. - -TIP: Messages are only sent to directly connected peers. This means -that in the event that a peer is connected indirectly, it will not -receive messages. When using this protocol to build mesh networks, it -is therefore important that a _fully-connected_ mesh network be -constructed. - -All message delivery in this pattern is best-effort, which means that -peers may not receive messages. Furthermore, delivery may occur to some, -all, or none of the directly connected peers. (Messages are not delivered -when peer nodes are unable to receive.) Hence, send operations will never -block; instead if the message cannot be delivered for any reason it is -discarded. - -TIP: In order to minimize the likelihood of message loss, this protocol -should not be used for high throughput communications. Furthermore, the -more traffic _in aggregate_ that occurs across the topology, the more -likely that message loss is to occur. - -=== Socket Operations - -The `nng_bus0_open()` call creates a bus socket. This socket -may be used to send and receive messages. Sending messages will -attempt to deliver to each directly connected peer. - -=== Protocol Versions - -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) - -=== Protocol Options - -The _nng_bus_ protocol has no protocol-specific options. - -=== Protocol Headers - -The _nng_bus_ protocol has no protocol-specific headers. - -== SEE ALSO - -<> diff --git a/docs/man/nng_bus_open.3.adoc b/docs/man/nng_bus_open.3.adoc new file mode 100644 index 000000000..119dc4e3e --- /dev/null +++ b/docs/man/nng_bus_open.3.adoc @@ -0,0 +1,44 @@ += nng_bus_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_bus_open - create bus socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_bus0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_bus0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_close.adoc b/docs/man/nng_close.3.adoc similarity index 56% rename from docs/man/nng_close.adoc rename to docs/man/nng_close.3.adoc index dfc1b0a6b..64bbf712f 100644 --- a/docs/man/nng_close.adoc +++ b/docs/man/nng_close.3.adoc @@ -24,14 +24,15 @@ int nng_close(nng_socket s); == DESCRIPTION -The `nng_close()` function closes the supplied socket, _s_. Messages -that have been submitted for sending may be flushed or delivered, -depending upon the transport and the setting of the `NNG_OPT_LINGER` -option. +The `nng_close()` function closes the supplied socket, _s_. +Messages that have been submitted for sending may be flushed or delivered, +depending upon the transport and the setting of the +<> option. Further attempts to use the socket after this call returns will result -in `NNG_EBADF`. Threads waiting for operations on the socket when this -call is executed may also return with an `NNG_EBADF` result. +in `NNG_ECLOSED`. +Threads waiting for operations on the socket when this +call is executed may also return with an `NNG_ECLOSED` result. == RETURN VALUES @@ -39,10 +40,11 @@ This function returns 0 on success, and non-zero otherwise. == ERRORS -`NNG_EBADF`:: The socket _s_ is already closed or was never opened. +`NNG_ECLOSED`:: The socket _s_ is already closed or was never opened. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_compat.3compat.adoc b/docs/man/nng_compat.3compat.adoc new file mode 100644 index 000000000..cc6271f4d --- /dev/null +++ b/docs/man/nng_compat.3compat.adoc @@ -0,0 +1,96 @@ += nng_compat(3compat) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_compat - compatibility with nanomsg 1.0 + +== SYNOPSIS + +[source, c] +---- +#include +---- + +== DESCRIPTION + +The <> library provides source-level compatibility for +most _nanomsg_ 1.0 applications. + +IMPORTANT: This is intended to faciliate converting legacy applications to +use the _nng_ library. +New applications shoud not use the newer <> API instead. + +Applications making use of this ((compatibility layer)) take care +to link with <> instead of _libnn_. + +NOTE: Some capabilities, protocols, and transports, will not be accessible +using this API, as the compatible API has no provision for expression +of certain concepts introduced in the newer <> API. + +NOTE: While reasonable efforts have been made to provide for compatibility, +some things may behave differently, and some less common parts of the +_nanomsg_ 1.0 API are not supported at this time, including certain +options and the statistics API. + +TIP: If an installation of the older _nanomsg_ library is present on +the build system, it may be necessary to provide a different search +path for header files to ensure that the compatibility definitions are +used in compilation. + +=== Functions + +The following functions are provided: + +// Add links for the following as they are written. +|=== +|`nn_socket()`|create a socket +|`nn_getsockopt()`|get socket option +|`nn_setsockopt()`|set socket option +|`nn_bind()`|accept connections from remote peers +|`nn_connect()`|connect to remote peer +|`nn_send()`|send data +|`nn_recv()`|receive data +|`nn_shutdown()`|shut down endpoint +|`nn_close()`|close socket +|`nn_poll()`|poll sockets +|`nn_device()`|create forwarding device +|`nn_recvmsg()`|receive message +|`nn_sendmsg()`|send message +|`nn_get_statistic()`|get statistic (stub) +|`nn_allocmsg()`|allocate message +|`nn_reallocmsg()`|reallocate message +|`nn_freemsg()`|free message +|`nn_errno()`|return most recent error +|`nn_strerror()`|return message for error +|`nn_term()`|terminate library +|=== + +NOTE: Documentation for the compatibility functions will be +supplied here later. +In the meantime it can be found online at the +http://nanomsg.org[nanomsg site]. + +// === Common Functions +// +// The following common functions exist in _libnng_. +// +// |=== +// |<>|allocate memory +// |<>|free memory +// |<>|return an error description +// |<>|report library version +// |=== +// + +== SEE ALSO + +<> diff --git a/docs/man/nng_device.3.adoc b/docs/man/nng_device.3.adoc new file mode 100644 index 000000000..807808848 --- /dev/null +++ b/docs/man/nng_device.3.adoc @@ -0,0 +1,104 @@ += nng_device(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sendmsg - send message + +== SYNOPSIS + +[source, c] +---- +#include + +int nng_device(nng_socket s1, nng_socket s2); +---- + +== DESCRIPTION + +The `nng_device()` function forwards messages received from one +<> _s1_ to another socket _s2_, and vice versa. + +This function is used to create forwarders, which can be used to create +complex network topologies to provide for improved ((horizontal scalability)), +reliability, and isolation. + +The `nng_device()` function does not return until one of the sockets +is closed. + +=== Reflectors + +One of the sockets may be passed the special value `-1` (cast to an, +<> of course). +If this is the case, then the other socket must be valid, and must be +a protocol that is bidirectional and can peer with itself (such as +<> or +<>.) +In this case the device acts as a ((reflector)) or loop-back device, +where messages received from the valid socket are merely returned +back to the sender. + +=== Forwarders + +When both sockets are valid, then the result is a ((forwarder)) or proxy. +In this case sockets _s1_ and _s2_ must be "`compatible`" with each other, +which is to say that they should represent the opposite halves of a two +protocol pattern, or both be the same protocol for a single protocol +pattern. +For example, if _s1_ is a <> socket, then _s2_ must +be a <> socket. +Or, if _s1_ is a <> socket, then _s2_ must also +be a _bus_ socket. + +=== Operation + +This `nng_device()` function puts each socket into raw mode +(see <>), and then moves messages +between them. +When a protocol has a ((backtrace)) style header, routing information is +added as the message crosses the forwarder, allowing replies to be +returned to requestors, and responses to be routed back to surveyors. + +Additionally, some protocols have a maximum ((time-to-live)) to protect +against forwarding loops and especially amplification loops. +In these cases, the default limit (usually 8), ensures that messages will +self-terminate when they have passed through too many forwarders, +protecting the network from unlimited message amplification that can arise +through misconfiguration. +This is controlled via the <> +option. + +IMPORTANT: Not all protocols have support for guarding against forwarding loops, +and even for those that do, forwarding loops can be extremely determintal +to network performance. + +NOTE: Devices (forwarders and reflectors) act in best effort delivery mode only. +If a message is received from one socket that cannot be accepted by the +other (due to backpressure or other issues), then the message is discarded. + +TIP: Use the request/reply pattern, which includes automatic retries by +the requestor, if reliable delivery is needed. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ECLOSED`:: At least one of the sockets is not open. +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_EINVAL`:: The sockets are not compatible, or are both invalid. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_dial.adoc b/docs/man/nng_dial.3.adoc similarity index 63% rename from docs/man/nng_dial.adoc rename to docs/man/nng_dial.3.adoc index 18d551370..c2044dfb2 100644 --- a/docs/man/nng_dial.adoc +++ b/docs/man/nng_dial.3.adoc @@ -16,35 +16,39 @@ nng_dial - create and start dialer == SYNOPSIS [source, c] ------------ +---- #include int nng_dial(nng_socket s, const char *url, nng_dialer *dp, int flags); ------------ +---- == DESCRIPTION The `nng_dialer()` function creates a newly initialized -dialer, associated with socket _s_, and configured to listen at the -address specified by _url_. If the value of _dp_ is not `NULL`, then +<> object, +associated with socket _s_, and configured to listen at the +address specified by _url_, and starts it. +If the value of _dp_ is not `NULL`, then the newly created dialer is stored at the address indicated by _dp_. -Dialers initiate a remote connection to a listener. Upon a successful -connection being established, they create a pipe, add it to the socket, -and then wait for that pipe to be closed. When the pipe is closed, -they will re-initiate the connection. Dialer's will also periodically -retry a connection automatically if an attempt to connect asynchronously -fails. +Dialers initiate a remote connection to a listener. +Upon a successful +connection being established, they create a <>, +add it to the socket, and then wait for that pipe to be closed. +When the pipe is closed, the dialer attempts to re-establish the connection. +Dialers will also periodically retry a connection automatically if an attempt +to connect asynchronously fails. -TIP: While it is convenient to think of dialers as "clients", the relationship +TIP: While it is convenient to think of dialers as "`clients``", the relationship between the listener or dialer is orthogonal to any server or client status -that might be associated with a given protocol. For example, a <> +that might be associated with a given protocol. +For example, a <> socket might have associated dialers, but might also have associated listeners. It may even have some of each at the same time! Normally, the first attempt to connect to the address indicated by _url_ is done -synchronously, including any necessary name resolution. As a result, -a failure, such as if the connection is refused, will be returned +synchronously, including any necessary name resolution. +As a result, a failure, such as if the connection is refused, will be returned immediately, and no further action will be taken. However, if the special value `NNG_FLAG_NONBLOCK` is @@ -58,8 +62,8 @@ it also generally makes diagnosing failures somewhat more difficult. Because the dialer is started immediately, it is generally not possible to apply extra configuration; if that is needed applications should consider -using <> and -<> instead. +using <> and +<> instead. == RETURN VALUES @@ -79,9 +83,11 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<>, -<>, -<>, -<> +<>, +<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_dialer.5.adoc b/docs/man/nng_dialer.5.adoc new file mode 100644 index 000000000..daadbd0b8 --- /dev/null +++ b/docs/man/nng_dialer.5.adoc @@ -0,0 +1,67 @@ += nng_dialer(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_dialer - dialer + +== SYNOPSIS + +[source, c] +----------- +#include + +typedef uint32_t nng_dialer; +----------- + +== DESCRIPTION + +(((dialer))) +An `nng_dialer` is a handle to a "`dialer`" object, which is responsible for +creating a single <> at a time by +establishing an outgoing connection. + +If the connection is broken, or fails, the dialer object will automatically +attempt to reconnect, and will keep doing so until the dialer or socket is +destroyed. + +Dialer objects are created by the +<> +or <> functions, and are always "`owned`" +by a single <>. + +TIP: A given <> may have multiple dialer +objects, multiple <> objects, or even some +of both. + +TIP: The client/server relationship described by dialer/listener is +completely orthogonal to any similar relationship in the protocols. +For example, a <> socket may use a dialer +to connect to a listener on an <> socket. +This orthogonality can lead to innovative solutions to otherwise +challenging communications problems. + +Dialer objects may be destroyed by the +<> function. +They are also closed when their "`owning`" socket is closed. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_dialer_close.adoc b/docs/man/nng_dialer_close.3.adoc similarity index 63% rename from docs/man/nng_dialer_close.adoc rename to docs/man/nng_dialer_close.3.adoc index 82ca6fc35..01ac91ed3 100644 --- a/docs/man/nng_dialer_close.adoc +++ b/docs/man/nng_dialer_close.3.adoc @@ -11,29 +11,30 @@ == NAME -nng_listener_close - close listener +nng_dialer_close - close dialer == SYNOPSIS [source, c] ------------ +---- #include int nng_dialer_close(nng_dialer d); ------------ +---- == DESCRIPTION The `nng_dialer_close()` function closes the listener _d_. -This also closes any pipe that has been created by the dialer. +This also closes any <> ojects that have +been created by the dialer. Once this function returns, the dialer _d_ and any of its resources -are deallocated. Therefore it is an error to attempt to access _d_ -after this function has returned. (Attempts to do so will result in -`NNG_ECLOSED` errors.) +are deallocated. +Therefore it is an error to attempt to access _d_ after +this function has returned. +(Attempts to do so will result in `NNG_ECLOSED` errors.) -Dialers are implicitly closed when the socket they are associated with -is closed. +Dialers are implicitly closed when the socket they are associated with is closed. == RETURN VALUES @@ -45,8 +46,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> -<>, -<> +<>, +<>, +<> +<>, +<>, +<> diff --git a/docs/man/nng_dialer_create.adoc b/docs/man/nng_dialer_create.3.adoc similarity index 57% rename from docs/man/nng_dialer_create.adoc rename to docs/man/nng_dialer_create.3.adoc index 02b7796bb..3181f10e0 100644 --- a/docs/man/nng_dialer_create.adoc +++ b/docs/man/nng_dialer_create.3.adoc @@ -16,41 +16,44 @@ nng_dialer_create - create dialer == SYNOPSIS [source, c] ------------ +---- #include int nng_dialer_create(nng_dialer *dialerp, nng_socket s, const char *url); ------------ +---- == DESCRIPTION The `nng_dialer_create()` function creates a newly initialized -dialer, associated with socket _s_, and configured to connect to the +<> object, associated with socket _s_, +and configured to connect to the address specified by _url_, and stores a pointer to at the location referenced by _dialerp_. -Dialers initiate a remote connection to a listener. Upon a successful +Dialers initiate a remote connection to a listener. +Upon a successful connection being established, they create a pipe, add it to the socket, -and then wait for that pipe to be closed. When the pipe is closed, -they will re-initiate the connection. Dialer's will also periodically -retry a connection automatically if an attempt to connect asynchronously +and then wait for that pipe to be closed. +When the pipe is closed, they will re-initiate the connection. +Dialers will also periodically retry a connection automatically if +an attempt to connect asynchronously fails. -TIP: While it is convenient to think of dialers as "clients", the relationship +TIP: While it is convenient to think of dialers as "`clients`", the relationship between the listener or dialer is orthogonal to any server or client status -that might be associated with a given protocol. For example, a <> +that might be associated with a given protocol. +For example, a <> socket might have associated dialers, but might also have associated listeners. It may even have some of each at the same time! The dialer is not started, but may be further configured with -the <> family of -functions. +the <> family of functions. Once it is fully configured, the dialer may be started using the -<> function. +<> function. TIP: If no specific configuration is required, consider using the -simpler <> function instead. +simpler <> function instead. == RETURN VALUES @@ -64,11 +67,12 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> +<>, +<>, +<> diff --git a/docs/man/nng_dialer_getopt.adoc b/docs/man/nng_dialer_getopt.3.adoc similarity index 91% rename from docs/man/nng_dialer_getopt.adoc rename to docs/man/nng_dialer_getopt.3.adoc index c4263262c..8dad06d1d 100644 --- a/docs/man/nng_dialer_getopt.adoc +++ b/docs/man/nng_dialer_getopt.3.adoc @@ -16,7 +16,7 @@ nng_dialer_getopt - get dialer option == SYNOPSIS [source, c] ------------ +---- #include int nng_dialer_getopt(nng_dialer d, const char *opt, void *val, size_t *valszp); @@ -30,13 +30,14 @@ int nng_dialer_getopt_ptr(nng_dialer d, const char *opt, void **ptr); int nng_dialer_setopt_size(nng_dialer d, const char *opt, size_t *zp); int nng_dialer_getopt_uint64(nng_dialer d, const char *opt, uint64_t *u64p); ------------ +---- == DESCRIPTION The `nng_dialer_getopt()` functions are used to retrieve option values for -the dialer _d_. The actual options that may be retrieved in this way -vary, and are documented in the <> manual. +the dialer _d_. +The actual options that may be retrieved in this way +vary, and many are documented in <>. Additionally some transport-specific options are documented with the transports themselves. @@ -109,9 +110,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<> -<>, -<>, -<> +<> +<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_dialer_setopt.adoc b/docs/man/nng_dialer_setopt.3.adoc similarity index 83% rename from docs/man/nng_dialer_setopt.adoc rename to docs/man/nng_dialer_setopt.3.adoc index d6a947148..311a61235 100644 --- a/docs/man/nng_dialer_setopt.adoc +++ b/docs/man/nng_dialer_setopt.3.adoc @@ -16,7 +16,7 @@ nng_dialer_setopt - set dialer option == SYNOPSIS [source, c] ------------ +---- #include int nng_dialer_setopt(nng_dialer d, const char *opt, const void *val, @@ -33,13 +33,14 @@ int nng_dialer_setopt_size(nng_dialer d, const char *opt, size_t z); int nng_dialer_setopt_string(nng_dialer d, const char *opt, const char *str); int nng_dialer_setopt_uint64(nng_dialer d, const char *opt, uint64_t u64); ------------ +---- == DESCRIPTION The `nng_dialer_setopt()` functions are used to configure options for -the dialer _d_. The actual options that may be configured in this way -vary, and are documented in the <> manual. +the dialer _d_. +The actual options that may be configured in this way +vary, and many are documented in <>. Additionally some transport-specific options are documented with the transports themselves. @@ -68,7 +69,7 @@ The fourth form, `nng_dialer_setopt_ptr()`, is used to pass a pointer _ptr_ to structured data. The data referenced by _ptr_ is generally managed by other functions. For example, TLS configuration objects -(<>) can be passed this way. +(<>) can be passed this way. Note that this form is somewhat special in that the object is generally not copied, but instead the *pointer* to the object is copied. @@ -77,12 +78,15 @@ specified by _z_, typically for buffer sizes, message maximum sizes, and similar options. The sixth form, `nng_dialer_setopt_string()`, is used to pass a string -_str_. Strings passed this way must be legal UTF-8 or ASCII strings, terminated -with a `NUL` (`\0`) byte. (Other constraints may apply as well, see the +_str_. +Strings passed this way must be legal UTF-8 or ASCII strings, terminated +with a `NUL` (`\0`) byte. +(Other constraints may apply as well, see the documentation for _opt_ for details.) The seventh form, `nng_dialer_setopt_uint64()`, is used to configure -the 64-bit unsigned value in _u64_. This is typically used for options +the 64-bit unsigned value in _u64_. +This is typically used for options related to identifiers, network numbers, and similar. NOTE: Once a dialer has started, it is generally not possible to change @@ -102,9 +106,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<> -<>, -<>, -<> +<> +<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_dialer_start.adoc b/docs/man/nng_dialer_start.3.adoc similarity index 86% rename from docs/man/nng_dialer_start.adoc rename to docs/man/nng_dialer_start.3.adoc index db6d7c07d..45dd0d6fa 100644 --- a/docs/man/nng_dialer_start.adoc +++ b/docs/man/nng_dialer_start.3.adoc @@ -16,11 +16,11 @@ nng_dialer_start - start dialer == SYNOPSIS [source, c] ------------ +---- #include int nng_dialer_start(nng_dialer d, int flags); ------------ +---- == DESCRIPTION @@ -33,8 +33,8 @@ When a connection is established, it results in a pipe being created, which will be attached to the dialer's socket. Normally, the first attempt to connect to the dialer's address is done -synchronously, including any necessary name resolution. As a result, -a failure, such as if the connection is refused, will be returned +synchronously, including any necessary name resolution. +As a result, a failure, such as if the connection is refused, will be returned immediately, and no further action will be taken. However, if the special value `NNG_FLAG_NONBLOCK` is @@ -47,7 +47,7 @@ TIP: While `NNG_FLAG_NONBLOCK` can help an application be more resilient, it also generally makes diagnosing failures somewhat more difficult. Once a dialer has started, it is generally not possible to change -it's configuration. +its configuration. == RETURN VALUES @@ -68,7 +68,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<>, -<> +<>, +<> +<>, +<>, +<> diff --git a/docs/man/nng_duration.adoc b/docs/man/nng_duration.5.adoc similarity index 76% rename from docs/man/nng_duration.adoc rename to docs/man/nng_duration.5.adoc index e44176099..381d2ea43 100644 --- a/docs/man/nng_duration.adoc +++ b/docs/man/nng_duration.5.adoc @@ -16,7 +16,7 @@ nng_duration - relative time in milliseconds == SYNOPSIS [source, c] ------------ +---- #include typedef int32_t nng_duration; @@ -24,26 +24,26 @@ typedef int32_t nng_duration; #define NNG_DURATION_INFINITE (-1) #define NNG_DURATION_DEFAULT (-2) #define NNG_DURATION_ZERO (0) ------------ +---- == DESCRIPTION -An ((`nng_duration`))(((duration))) is a relative time, measured in +An `nng_duration`(((duration))) is a relative time, measured in milliseconds. This type is most often used in conjuction with timers and timeouts. A couple of special values have been set aside, and carry special meanings. -[[NNG_DURATION_DEFAULT]]((`NNG_DURATION_DEFAULT`))::: +((`NNG_DURATION_DEFAULT`))::: Indicates a context-specific default value should be used. -[[NNG_DURATION_INFINITE]]((`NNG_DURATION_INFINITE`))::: +((`NNG_DURATION_INFINITE`))::: Effectively an infinite duration; used most often to disable timeouts. -[[NNG_DURATION_ZERO]]((`NNG_DURATION_ZERO`))::: +((`NNG_DURATION_ZERO`))::: Zero length duration; used to perform a single polling operation. == SEE ALSO -[.text-left] -<>, -<> + +<>, +<> diff --git a/docs/man/nng_free.adoc b/docs/man/nng_free.3.adoc similarity index 76% rename from docs/man/nng_free.adoc rename to docs/man/nng_free.3.adoc index 2b7b09a50..c5588a1cf 100644 --- a/docs/man/nng_free.adoc +++ b/docs/man/nng_free.3.adoc @@ -16,24 +16,25 @@ nng_free - free memory == SYNOPSIS [source, c] ------------ +---- #include void nng_free(void *ptr, size_t size); ------------ +---- == DESCRIPTION The `nng_free()` function deallocates a memory region of size _size_, -that was previously allocated by <> or -<> with the `NNG_FLAG_ALLOC` flag. +that was previously allocated by <> or +<> with the `NNG_FLAG_ALLOC` flag. WARNING: It is very important that _size_ match the allocation size used to allocate the memory. WARNING: Do not attempt to use this function to deallocate memory obtained by a call to the system `malloc()` or `calloc()` functions, -or the {cpp} `new` operator. Doing so may result in unpredictable +or the {cpp} `new` operator. +Doing so may result in unpredictable behavior, including corruption of application memory. == RETURN VALUES @@ -46,6 +47,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_getopt.adoc b/docs/man/nng_getopt.3.adoc similarity index 89% rename from docs/man/nng_getopt.adoc rename to docs/man/nng_getopt.3.adoc index 322927cc0..ef69103c8 100644 --- a/docs/man/nng_getopt.adoc +++ b/docs/man/nng_getopt.3.adoc @@ -34,10 +34,10 @@ int nng_getopt_uint64(nng_socket s, const char *opt, uint64_t *u64p); == DESCRIPTION -The `((nng_getopt))()` functions are used to retrieve option values for +The `nng_getopt()` functions are used to retrieve option values for the socket _s_. The actual options that may be retrieved in this way vary. -A number of them are documented in <>. +A number of them are documented in <>. Additionally transport-specific options and protocol-specific options are documented with the transports and protocols themselves. @@ -112,11 +112,11 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -[.text-left] -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_client_alloc.adoc b/docs/man/nng_http_client_alloc.3http.adoc similarity index 80% rename from docs/man/nng_http_client_alloc.adoc rename to docs/man/nng_http_client_alloc.3http.adoc index 40499862d..f6fa28626 100644 --- a/docs/man/nng_http_client_alloc.adoc +++ b/docs/man/nng_http_client_alloc.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_client_alloc(3) += nng_http_client_alloc(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -40,8 +40,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_client_connect.adoc b/docs/man/nng_http_client_connect.3http.adoc similarity index 79% rename from docs/man/nng_http_client_connect.adoc rename to docs/man/nng_http_client_connect.3http.adoc index f5fef4ebe..47fcb4e07 100644 --- a/docs/man/nng_http_client_connect.adoc +++ b/docs/man/nng_http_client_connect.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_client_connect(3) += nng_http_client_connect(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -31,12 +31,12 @@ _client_ was configured with. The result of the operation will be stored in the _aio_ when the operation is complete, and will be obtainable via -<>. +<>. On success, a pointer to the underlying HTTP client (type `nng_http_conn *`) will be stored in the first output result of the _aio_, and can be obtained by -<> with an _index_ of zero (0). +<> with an _index_ of zero (0). == RETURN VALUES @@ -85,12 +85,12 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_client_free.adoc b/docs/man/nng_http_client_free.3http.adoc similarity index 77% rename from docs/man/nng_http_client_free.adoc rename to docs/man/nng_http_client_free.3http.adoc index e54c7bd54..6158143c2 100644 --- a/docs/man/nng_http_client_free.adoc +++ b/docs/man/nng_http_client_free.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_client_free(3) += nng_http_client_free(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -29,7 +29,7 @@ The `nng_http_client_free()` frees the HTTP client and any associated resources referenced by _client_. NOTE: Any connections created by -<> are unaffected, +<> are unaffected, and so the caller must close those explicitly if desired. == RETURN VALUES @@ -42,6 +42,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_client_get_tls.adoc b/docs/man/nng_http_client_get_tls.3http.adoc similarity index 76% rename from docs/man/nng_http_client_get_tls.adoc rename to docs/man/nng_http_client_get_tls.3http.adoc index 7aa5fd277..1632ecda4 100644 --- a/docs/man/nng_http_client_get_tls.adoc +++ b/docs/man/nng_http_client_get_tls.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_client_get_tls(3) += nng_http_client_get_tls(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -42,9 +42,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_client_set_tls.adoc b/docs/man/nng_http_client_set_tls.3http.adoc similarity index 66% rename from docs/man/nng_http_client_set_tls.adoc rename to docs/man/nng_http_client_set_tls.3http.adoc index deed7e570..756867786 100644 --- a/docs/man/nng_http_client_set_tls.adoc +++ b/docs/man/nng_http_client_set_tls.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_client_set_tls(3) += nng_http_client_set_tls(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -25,16 +25,15 @@ int nng_http_client_set_tls(nng_http_client *client, nng_tls_config *cfg); == DESCRIPTION -The `nng_http_client_set_tls()` sets the TLS configuration of _client_ to -_cfg_. +The `nng_http_client_set_tls()` sets the TLS configuration of _client_ to _cfg_. This change overwrites any previous TLS configuration. -WARNING: This also invalidates any previously obtained values from -<>. +IMPORTANT: This also invalidates any previously obtained values from +<>. NOTE: Any connections established with -<> +<> will continue to use any TLS configuration that they were started with. == RETURN VALUES @@ -48,9 +47,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_close.adoc b/docs/man/nng_http_conn_close.3http.adoc similarity index 79% rename from docs/man/nng_http_conn_close.adoc rename to docs/man/nng_http_conn_close.3http.adoc index 38de10f0e..2861fa1b7 100644 --- a/docs/man/nng_http_conn_close.adoc +++ b/docs/man/nng_http_conn_close.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_close(3) += nng_http_conn_close(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_conn_close - close HTTP connection == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_close(nng_http_conn *conn); ------------ +---- == DESCRIPTION @@ -40,7 +40,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_read.adoc b/docs/man/nng_http_conn_read.3http.adoc similarity index 58% rename from docs/man/nng_http_conn_read.adoc rename to docs/man/nng_http_conn_read.3http.adoc index 14d5e1af3..d6094ff01 100644 --- a/docs/man/nng_http_conn_read.adoc +++ b/docs/man/nng_http_conn_read.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_read(3) += nng_http_conn_read(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_conn_read - read from HTTP connection == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_read(nng_http_conn *conn, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -29,22 +29,24 @@ The `nng_http_conn_read()` function starts an asynchronous read from the HTTP connection _conn_, into the scatter/gather vector located in the asynchronous I/O structure _aio_. -NOTE: The <> function must have been +NOTE: The <> function must have been called first, to set the scatter/gather vector for _aio_. -This function returns immediately, with no return value. Completion of -the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, +and the final result may be obtained via +<>. +That result will either be zero or an error code. The I/O operation completes as soon as at least one byte has been read, or an error has occurred. -Therefore, the number of bytes read may be less than requested. The actual -number of bytes read can be determined with <>. +Therefore, the number of bytes read may be less than requested. +The actual number of bytes read can be determined with +<>. TIP: This function is intended to facilitate uses cases that involve changing -the protocol from HTTP -- such as WebSocket. Most applications will never need -to use this function. +the protocol from HTTP, such as WebSocket. +Most applications will never need to use this function. == RETURN VALUES @@ -62,12 +64,12 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_read_all.adoc b/docs/man/nng_http_conn_read_all.3http.adoc similarity index 78% rename from docs/man/nng_http_conn_read_all.adoc rename to docs/man/nng_http_conn_read_all.3http.adoc index f98eedd5b..78a89a13d 100644 --- a/docs/man/nng_http_conn_read_all.adoc +++ b/docs/man/nng_http_conn_read_all.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_read_all(3) += nng_http_conn_read_all(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_conn_read_all - read all from HTTP connection == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_read_all(nng_http_conn *conn, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -29,12 +29,12 @@ The `nng_http_conn_read_all()` function starts an asynchronous read from the HTTP connection _conn_, into the scatter/gather vector located in the asynchronous I/O structure _aio_. -NOTE: The <> function must have been +NOTE: The <> function must have been called first, to set the scatter/gather vector for _aio_. This function returns immediately, with no return value. Completion of the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will +obtained via <>. That result will either be zero or an error code. The I/O operation completes only when the entire amount of data @@ -43,7 +43,7 @@ completes successfully, then the entire requested data has been read. It is still possible for a partial read to complete in the event of an error. The actual number of bytes read can be determined with -<>. +<>. TIP: The main purpose for this function is to faciliate reading HTTP body content, after first determining the length of the body content @@ -65,11 +65,11 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_read_req.adoc b/docs/man/nng_http_conn_read_req.3http.adoc similarity index 63% rename from docs/man/nng_http_conn_read_req.adoc rename to docs/man/nng_http_conn_read_req.3http.adoc index d12c736b0..e667455df 100644 --- a/docs/man/nng_http_conn_read_req.adoc +++ b/docs/man/nng_http_conn_read_req.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_read_req(3) += nng_http_conn_read_req(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,13 +16,13 @@ nng_http_conn_read_req - read HTTP request == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_read_req(nng_http_conn *conn, nng_http_req *req, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -31,14 +31,15 @@ HTTP connection _conn_, reading an HTTP request into the _req_, including all of the related headers. NOTE: Any HTTP entity/body data associated with the request is *not* read -automatically. The caller should use -<> to read the entity -data, based on the details of the request itself. +automatically. +The caller should use +<> +to read the entity data, based on the details of the request itself. -This function returns immediately, with no return value. Completion of -the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, and the final result +may be obtained via <>. +That result will either be zero or an error code. == RETURN VALUES @@ -55,9 +56,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_read_res.adoc b/docs/man/nng_http_conn_read_res.3http.adoc similarity index 69% rename from docs/man/nng_http_conn_read_res.adoc rename to docs/man/nng_http_conn_read_res.3http.adoc index 611d194c0..6e00adc89 100644 --- a/docs/man/nng_http_conn_read_res.adoc +++ b/docs/man/nng_http_conn_read_res.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_read_res(3) += nng_http_conn_read_res(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,13 +16,13 @@ nng_http_conn_read_res - read HTTP response == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_read_res(nng_http_conn *conn, nng_http_res *res, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -31,14 +31,16 @@ HTTP connection _conn_, reading an HTTP response into the _res_, including all of the related headers. NOTE: Any HTTP entity/body data associated with the response is *not* read -automatically. The caller should use -<> to read the entity +automatically. +The caller should use +<> to read the entity data, based on the details of the response itself. -This function returns immediately, with no return value. Completion of +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +obtained via <>. +That result will either be zero or an error code. == RETURN VALUES @@ -55,9 +57,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_write.adoc b/docs/man/nng_http_conn_write.3http.adoc similarity index 61% rename from docs/man/nng_http_conn_write.adoc rename to docs/man/nng_http_conn_write.3http.adoc index 85df3ed92..d4f65cacb 100644 --- a/docs/man/nng_http_conn_write.adoc +++ b/docs/man/nng_http_conn_write.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_write(3) += nng_http_conn_write(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_conn_write - write to HTTP connection == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_write(nng_http_conn *conn, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -29,23 +29,23 @@ The `nng_http_conn_write()` function starts an asynchronous write to the HTTP connection _conn_ from the scatter/gather vector located in the asynchronous I/O structure _aio_. -NOTE: The <> function must have been +NOTE: The <> function must have been called first, to set the scatter/gather vector for _aio_. -This function returns immediately, with no return value. Completion of -the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, and the final +result may be obtained via <>. +That result will either be zero or an error code. The I/O operation completes as soon as at least one byte has been written, or an error has occurred. -Therefore, the number of bytes written may be less than requested. The actual -number of bytes written can be determined with -<>. +Therefore, the number of bytes written may be less than requested. +The actual number of bytes written can be determined with +<>. TIP: This function is intended to facilitate uses cases that involve changing -the protocol from HTTP -- such as WebSocket. Most applications will never need -to use this function. +the protocol from HTTP, such as WebSocket. +Most applications will never need to use this function. == RETURN VALUES @@ -63,12 +63,12 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_write_all.adoc b/docs/man/nng_http_conn_write_all.3http.adoc similarity index 51% rename from docs/man/nng_http_conn_write_all.adoc rename to docs/man/nng_http_conn_write_all.3http.adoc index df75be71e..f517a9a51 100644 --- a/docs/man/nng_http_conn_write_all.adoc +++ b/docs/man/nng_http_conn_write_all.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_write_all(3) += nng_http_conn_write_all(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_conn_write_all - write all to HTTP connection == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_write_all(nng_http_conn *conn, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -29,37 +29,37 @@ The `nng_http_conn_write_all()` function starts an asynchronous write to the HTTP connection _conn_, into the scatter/gather vector located in the asynchronous I/O structure _aio_. -NOTE: The <> function must have been +NOTE: The <> function must have been called first, to set the scatter/gather vector for _aio_. -This function returns immediately, with no return value. Completion of -the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, and the +final result may be obtained via <>. +That result will either be zero or an error code. The I/O operation completes only when the entire amount of data requested has been written, or an error has occurred. If the operation completes successfully, then the entire requested data has been written. -It is still possible for a partial write to complete in the event of an -error. The actual number of bytes written can be determined with -<>. +It is still possible for a partial write to complete in the event of an error. +The actual number of bytes written can be determined with +<>. TIP: The main purpose for this function is to faciliate writing HTTP body content. TIP: Usually an HTTP request or response will have been written immediately -prior to this with <> or -<>. In that case the -request or response should have also contained an `Content-Length` header, -and possibly a `Content-Type` header. +prior to this with <> or +<>. +In that case the request or response should have also contained +an `Content-Length` header, and possibly a `Content-Type` header. TIP: An easier solution to sending HTTP content data, is to include the conten with the request or reply using a function like -<>. In that case, -the body data will be written automatically by the -<> or -<> function. +<>. +In that case, the body data will be written automatically by the +<> or +<> function. == RETURN VALUES @@ -77,17 +77,17 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_write_req.adoc b/docs/man/nng_http_conn_write_req.3http.adoc similarity index 56% rename from docs/man/nng_http_conn_write_req.adoc rename to docs/man/nng_http_conn_write_req.3http.adoc index e47dd2541..2d614206c 100644 --- a/docs/man/nng_http_conn_write_req.adoc +++ b/docs/man/nng_http_conn_write_req.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_write_req(3) += nng_http_conn_write_req(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,27 +16,28 @@ nng_http_conn_write_req - write HTTP request == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_write_req(nng_http_conn *conn, nng_http_req *req, nng_aio *aio); ------------ +---- == DESCRIPTION The `nng_http_conn_write_req()` function starts an asynchronous write of -the HTTP request _req_ to the connection _conn_. The entire request is sent, -including headers, and if present, the request body data. (The -request body can be set with -<> or -<>.) - -This function returns immediately, with no return value. Completion of -the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +the HTTP request _req_ to the connection _conn_. +The entire request is sent, +including headers, and if present, the request body data. +(The request body can be set with +<> or +<>.) + +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, and the final result +may be obtained via <>. +That result willeither be zero or an error code. == RETURN VALUES @@ -53,9 +54,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_conn_write_res.adoc b/docs/man/nng_http_conn_write_res.3http.adoc similarity index 62% rename from docs/man/nng_http_conn_write_res.adoc rename to docs/man/nng_http_conn_write_res.3http.adoc index 72fc89ec7..c8d0077b3 100644 --- a/docs/man/nng_http_conn_write_res.adoc +++ b/docs/man/nng_http_conn_write_res.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_conn_write_res(3) += nng_http_conn_write_res(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,27 +16,28 @@ nng_http_conn_write_res - write HTTP response == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_conn_write_res(nng_http_conn *conn, nng_http_res *res, nng_aio *aio); ------------ +---- == DESCRIPTION The `nng_http_conn_write_res()` function starts an asynchronous write of -the HTTP response _res_ to the connection _conn_. The entire response is sent, -including headers, and if present, the response body data. (The -response body can be set with -<> or -<>.) - -This function returns immediately, with no return value. Completion of -the operation is signaled via the _aio_, and the final result may be -obtained via <>. That result will -either be zero or an error code. +the HTTP response _res_ to the connection _conn_. +The entire response is sent, +including headers, and if present, the response body data. +(The response body can be set with +<> or +<>.) + +This function returns immediately, with no return value. +Completion of the operation is signaled via the _aio_, and the final result +may be obtained via <>. +That result will either be zero or an error code. === Persistent Connections @@ -62,9 +63,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_alloc.adoc b/docs/man/nng_http_handler_alloc.3http.adoc similarity index 59% rename from docs/man/nng_http_handler_alloc.adoc rename to docs/man/nng_http_handler_alloc.3http.adoc index c45d2bfd4..e1238b8f5 100644 --- a/docs/man/nng_http_handler_alloc.adoc +++ b/docs/man/nng_http_handler_alloc.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_alloc(3) += nng_http_handler_alloc(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,7 +16,7 @@ nng_http_handler_alloc - allocate HTTP server handler == SYNOPSIS [source, c] ------------ +---- #include #include @@ -24,13 +24,16 @@ typedef struct nng_http_handler nng_http_handler; int nng_http_handler_alloc(nng_http_handler **hp, const char *path, void (*func)(nng_aio *); + int nng_http_handler_alloc_directory(nng_http_handler **hp, const char *path, const char *dirname); + int nng_http_handler_alloc_file(nng_http_handler **hp, const char *path, const char *filename); + int nng_http_handler_alloc_static(nng_http_handler **hp, const char *path, const void *data, size_t size, const char *content_type); ------------ +---- == DESCRIPTION @@ -40,60 +43,65 @@ On success, a pointer to the handler is stored at the located pointed to by _hp_. Every handler has a Request-URI to which it refers, which is determined -by the _path_ argument. Only the path component of the Request URI is +by the _path_ argument. +Only the path component of the Request URI is considered when determining whether the handler should be called. Additionally each handler has a method it is registered to handle (the default is "GET", see -<>), and +<>), and optionally a 'Host' header it can be matched against (see -<>). In some cases, a handler may reference a logical tree rather (directory) rather than just a single element. -(See <>). +(See <>). === Custom Handler The generic (first) form of this creates a handler that uses a user-supplied -function to process HTTP requests. This function uses the asynchronous I/O -framework. The function takes a pointer to an `nng_aio` structure. That -structure will be passed with the following input values (retrieved with -<>): +function to process HTTP requests. +This function uses the asynchronous I/O framework. +The function takes a pointer to an `nng_aio` structure. +That structure will be passed with the following input values (retrieved with +<>): 0: ``nng_http_req *`` __request__:: The client's HTTP request. 1: ``nng_http_handler *``__handler__:: Pointer to the handler object. 2: ``nng_http_conn *``__conn__:: The underlying HTTP connection. The handler should create an `nng_http_res *` response (such as via -<> or -<>) and store that +<> or +<>) and store that in as the first output (index 0) with -<>. +<>. Alternatively, the handler may send the HTTP response (and any associated -body data) itself using the connection. In that case the output at index -0 of the _aio_ should be NULL. +body data) itself using the connection. +In that case the output at index 0 of the _aio_ should be NULL. -Finally, using the <> function, the -_aio_ should be completed successfully. If any non-zero status is returned -back to the caller instead, then a generic 500 response will be created and +Finally, using the <> function, the +_aio_ should be completed successfully. +If any non-zero status is returned back to the caller instead, +then a generic 500 response will be created and sent, if possible, and the connection will be closed. === Directory Handler The second member of this family, `nng_http_handler_alloc_directory()`, creates -a handler configured to serve a directory tree. The _uri_ is taken as -the root, and files are served from the directory tree rooted at _path_. +a handler configured to serve a directory tree. +The _uri_ is taken as the root, and files are served from the directory +tree rooted at _path_. When the client Request-URI resolves to a directory in the filesystem, -the handler looks first for a file named `index.html` or `index.htm`. If -one is found, then that file is returned back to the client. If no such -index file exists, then an `NNG_HTTP_STATUS_NOT_FOUND` (404) error is +the handler looks first for a file named `index.html` or `index.htm`. +If one is found, then that file is returned back to the client. +If no such index file exists, then an `NNG_HTTP_STATUS_NOT_FOUND` (404) error is sent back to the client. The `Content-Type` will be set automatically based upon the extension -of the requsted file name. If a content type cannot be determined from +of the requsted file name. +If a content type cannot be determined from the extension, then `application/octet-stream` is used. === File Handler @@ -103,13 +111,15 @@ a handler to serve up a single file; it does not traverse directories or search for `index.html` or `index.htm` files. The `Content-Type` will be set automatically based upon the extension -of the requsted file name. If a content type cannot be determined from +of the requsted file name. +If a content type cannot be determined from the extension, then `application/octet-stream` is used. === Static Handler The fourth member of this family, `nng_http_handler_alloc_static()`, creates -a handler to serve up fixed content located in program data. The client is +a handler to serve up fixed content located in program data. +The client is sent the _data_, with `Content-Length` of _size_ bytes, and `Content-Type` of __content_type__. @@ -125,15 +135,15 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_free.adoc b/docs/man/nng_http_handler_free.3http.adoc similarity index 75% rename from docs/man/nng_http_handler_free.adoc rename to docs/man/nng_http_handler_free.3http.adoc index fe568513e..3528ff291 100644 --- a/docs/man/nng_http_handler_free.adoc +++ b/docs/man/nng_http_handler_free.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_free(3) += nng_http_handler_free(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,18 +16,18 @@ nng_http_handler_free - free HTTP server handler == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_handler_free(nng_http_handler *h); ------------ +---- == DESCRIPTION The `nng_http_handler_free()` function frees an allocated HTTP server handler. -CAUTION: It is an error to free a handler that is registered with a server. +IMPORTANT: It is an error to free a handler that is registered with a server. Any handlers that are registered with servers are automatically freed when the server itself is deallocated. @@ -41,6 +41,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_get_data.adoc b/docs/man/nng_http_handler_get_data.3http.adoc similarity index 70% rename from docs/man/nng_http_handler_get_data.adoc rename to docs/man/nng_http_handler_get_data.3http.adoc index de1390531..b179fd341 100644 --- a/docs/man/nng_http_handler_get_data.adoc +++ b/docs/man/nng_http_handler_get_data.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_get_data(3) += nng_http_handler_get_data(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,19 +16,19 @@ nng_http_handler_get_data - return extra data for HTTP handler == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_handler_get_data(nng_http_handler *handler, void *data, void (*dtor)(void *)); ------------ +---- == DESCRIPTION The `nng_http_handler_get_data()` function returns the data previously stored on _handler_ using the function -<>. +<>. == RETURN VALUES @@ -40,7 +40,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_set_data.adoc b/docs/man/nng_http_handler_set_data.3http.adoc similarity index 68% rename from docs/man/nng_http_handler_set_data.adoc rename to docs/man/nng_http_handler_set_data.3http.adoc index f1b742113..318919a99 100644 --- a/docs/man/nng_http_handler_set_data.adoc +++ b/docs/man/nng_http_handler_set_data.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_set_data(3) += nng_http_handler_set_data(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,23 +16,24 @@ nng_http_handler_get_data - set extra data for HTTP handler == SYNOPSIS [source, c] ------------ +---- #include #include void *nng_http_handler_get_data(nng_http_handler *handler, void *data, void (*dtor)(void *)); ------------ +---- == DESCRIPTION The `nng_http_handler_set_data()` function is used to set an additional -_data_ for the _handler_. The stored _data_ can be retrieved later -in the handler function using -<>. +_data_ for the _handler_. +The stored _data_ can be retrieved later in the handler function using +<>. Additionally, when the handler is deallocated, if _dtor_ is not `NULL`, -then it will be called with _data_ as its argument. The intended use of +then it will be called with _data_ as its argument. +The intended use of this function is deallocate any resources associated with _data_. == RETURN VALUES @@ -46,7 +47,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_set_host.adoc b/docs/man/nng_http_handler_set_host.3http.adoc similarity index 77% rename from docs/man/nng_http_handler_set_host.adoc rename to docs/man/nng_http_handler_set_host.3http.adoc index d3e464e35..c286540f4 100644 --- a/docs/man/nng_http_handler_set_host.adoc +++ b/docs/man/nng_http_handler_set_host.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_set_host(3) += nng_http_handler_set_host(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_handler_set_host - set host for HTTP handler == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_handler_set_host(nng_http_handler *handler, const char *host); ------------ +---- == DESCRIPTION @@ -33,11 +33,12 @@ TIP: This can be used to create servers with multiple handlers for virtual hosting. The value of the _host_ can include a colon and port, and should match -exactly the value of the `Host` header sent by the client. (Canonicaliztion -of the host name is performed though.) +exactly the value of the `Host` header sent by the client. +(Canonicaliztion of the host name is performed though.) TIP: As the server framework does not support listening on multiple -ports, the port number can be elided. The matching test only considers +ports, the port number can be elided. +The matching test only considers the hostname or IP address, and ignores any trailing port number. == RETURN VALUES @@ -51,6 +52,6 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_set_method.adoc b/docs/man/nng_http_handler_set_method.3http.adoc similarity index 73% rename from docs/man/nng_http_handler_set_method.adoc rename to docs/man/nng_http_handler_set_method.3http.adoc index 8769ffc80..d2ae88d01 100644 --- a/docs/man/nng_http_handler_set_method.adoc +++ b/docs/man/nng_http_handler_set_method.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_set_method(3) += nng_http_handler_set_method(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,18 +16,19 @@ nng_http_handler_set_method - set HTTP handler method == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_handler_set_method(nng_http_handler *handler, const char *method); ------------ +---- == DESCRIPTION The `nng_http_handler_set_method()` function sets the _method_ that the -_handler_ will be called for, such as "GET" or "POST". (By default the -"GET" method is handled.) If _method_ is `NULL`, then the request method +_handler_ will be called for, such as "GET" or "POST". +(By default the "GET" method is handled.) +If _method_ is `NULL`, then the request method is not examined, and the handler will be executed regardless of the method. @@ -39,7 +40,7 @@ NOTE: No validation of the _method_ is performed, but HTTP specifications insist that the actual method sent over the wire be capitalized. The handler may always examine the actual method used using the -<> function. +<> function. == RETURN VALUES @@ -52,7 +53,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_handler_set_tree.adoc b/docs/man/nng_http_handler_set_tree.3http.adoc similarity index 80% rename from docs/man/nng_http_handler_set_tree.adoc rename to docs/man/nng_http_handler_set_tree.3http.adoc index a21a66814..474ac64f6 100644 --- a/docs/man/nng_http_handler_set_tree.adoc +++ b/docs/man/nng_http_handler_set_tree.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_handler_set_tree(3) += nng_http_handler_set_tree(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_handler_set_tree - set HTTP handler to match trees == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_handler_set_tree(nng_http_handler *handler); ------------ +---- == DESCRIPTION @@ -43,7 +43,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_hijack.adoc b/docs/man/nng_http_hijack.3http.adoc similarity index 67% rename from docs/man/nng_http_hijack.adoc rename to docs/man/nng_http_hijack.3http.adoc index ef1c5b738..61f6d471a 100644 --- a/docs/man/nng_http_hijack.adoc +++ b/docs/man/nng_http_hijack.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_hijack(3) += nng_http_hijack(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,15 +16,15 @@ nng_http_hijack - hijack HTTP server connection == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_hijack(nng_http_conn *conn); ------------ +---- == DESCRIPTION - +(((HTTP, hijack))) The `nng_http_hijack()` function hijacks the connection _conn_, causing it to be disassociated from the HTTP server where it was created. @@ -33,17 +33,17 @@ WebSocket), where the underlying HTTP connection will be taken over for some other purpose, and should not be used any further by the server. This function is most useful when called from a handler function. -(See <>.) NOTE: It is the responsibility of the caller to dispose of the underlying -connection when it is no longer needed. Furthermore, the HTTP server will -no longer send any responses to the hijacked connection, so the caller should -do that as well if appropriate. (See -<>.) +connection when it is no longer needed. +Furthermore, the HTTP server will no longer send any responses to the +hijacked connection, so the caller should do that as well if appropriate. +(See <>.) TIP: This function is intended to facilitate uses cases that involve changing -the protocol from HTTP -- such as WebSocket. Most applications will never need -to use this function. +the protocol from HTTP, such as WebSocket. +Most applications will never need to use this function. == RETURN VALUES @@ -57,7 +57,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_add_header.adoc b/docs/man/nng_http_req_add_header.3http.adoc similarity index 76% rename from docs/man/nng_http_req_add_header.adoc rename to docs/man/nng_http_req_add_header.3http.adoc index eb4033344..d47e112e1 100644 --- a/docs/man/nng_http_req_add_header.adoc +++ b/docs/man/nng_http_req_add_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_add_header(3) += nng_http_req_add_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,13 +16,13 @@ nng_http_req_add_header - add HTTP request header == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_req_add_header(nng_http_req *req, const char *key, const char *val); ------------ +---- == DESCRIPTION @@ -37,11 +37,12 @@ If no such header already exists, then one is created with the value _val_. TIP: The HTTP specification requires that duplicate headers be treated identically to a single header with multiple comma-delimited values. -TIP: See <> if +TIP: See <> if replacement of an existing header rather than appending to it is desired. The value of _key_ is case insensitive, and should not include the final -colon in an HTTP header. For example, specifying `Host` or `hOSt` are +colon in an HTTP header. +For example, specifying `Host` or `hOSt` are equivalent, whereas the value `Host:` is not a legal header key. == RETURN VALUES @@ -55,8 +56,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_alloc.3http.adoc b/docs/man/nng_http_req_alloc.3http.adoc new file mode 100644 index 000000000..ab84478aa --- /dev/null +++ b/docs/man/nng_http_req_alloc.3http.adoc @@ -0,0 +1,61 @@ += nng_http_req_alloc(3http) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_http_req_alloc - allocate HTTP request structure + +== SYNOPSIS + +[source, c] +---- +#include +#include + +int nng_http_req_alloc(nng_http_req **reqp, const nng_url *url); +---- + +== DESCRIPTION + +The `nng_http_req_alloc()` function allocates a new HTTP request structure +and stores a pointer to it in __reqp__. +The request will be initialized +to perform an HTTP/1.1 `GET` operation using the URL specified in __url__. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient free memory exists to allocate a message. +`NNG_ENOTSUP`:: HTTP support not configured. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> +<>, +<> diff --git a/docs/man/nng_http_req_alloc.adoc b/docs/man/nng_http_req_alloc.adoc deleted file mode 100644 index f3aead520..000000000 --- a/docs/man/nng_http_req_alloc.adoc +++ /dev/null @@ -1,60 +0,0 @@ -= nng_http_req_alloc(3) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_http_req_alloc - allocate HTTP request structure - -== SYNOPSIS - -[source, c] ------------ -#include -#include - -int nng_http_req_alloc(nng_http_req **reqp, const nng_url *url); ------------ - -== DESCRIPTION - -The `nng_http_req_alloc()` function allocates a new HTTP request structure -and stores a pointer to it in __reqp__. The request will be initialized -to perform an HTTP/1.1 `GET` operation using the URL specified in __url__. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -`NNG_ENOMEM`:: Insufficient free memory exists to allocate a message. -`NNG_ENOTSUP`:: HTTP support not configured. - -== SEE ALSO - -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> -<>, -<> diff --git a/docs/man/nng_http_req_copy_data.adoc b/docs/man/nng_http_req_copy_data.3http.adoc similarity index 67% rename from docs/man/nng_http_req_copy_data.adoc rename to docs/man/nng_http_req_copy_data.3http.adoc index 184eaaa5c..1e08cea07 100644 --- a/docs/man/nng_http_req_copy_data.adoc +++ b/docs/man/nng_http_req_copy_data.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_copy_data(3) += nng_http_req_copy_data(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,21 +16,21 @@ nng_http_req_copy_data - copy HTTP request body == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_req_copy_data(nng_http_req *req, const void *body, size_t size); ------------ +---- == DESCRIPTION The `nng_http_req_copy_data()` makes a copy of _body_ (of size __size__) -and sets the HTTP body for the request _req_ to it. The copy will be -deallocated automatically when _req_ is freed. +and sets the HTTP body for the request _req_ to it. +The copy will be deallocated automatically when _req_ is freed. The copied body data will be automatically sent with the request when it -is sent using <>. +is sent using <>. This also updates the relevant `Content-Length` header of _req_. @@ -38,7 +38,7 @@ NOTE: The current framework does not support sending data via chunked transfer-encoding. TIP: To avoid copying data, the -<> may be used instead. +<> may be used instead. TIP: It is a good idea to also set the `Content-Type` header. @@ -53,8 +53,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_del_header.adoc b/docs/man/nng_http_req_del_header.3http.adoc similarity index 73% rename from docs/man/nng_http_req_del_header.adoc rename to docs/man/nng_http_req_del_header.3http.adoc index 3306e8c98..ff3d045f9 100644 --- a/docs/man/nng_http_req_del_header.adoc +++ b/docs/man/nng_http_req_del_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_set_header(3) += nng_http_req_set_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_req_set_header - set HTTP request header == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_req_set_header(nng_http_req *req, const char *key); ------------ +---- == DESCRIPTION @@ -29,7 +29,8 @@ The `nng_http_req_del_header()` removes all HTTP headers with the associated _key_ from the request structure _req_. The value of _key_ is case insensitive, and should not include the final -colon in an HTTP header. For example, specifying `Host` or `hOSt` are +colon in an HTTP header. +For example, specifying `Host` or `hOSt` are equivalent, whereas the value `Host:` is not a legal header key. == RETURN VALUES @@ -43,8 +44,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_free.adoc b/docs/man/nng_http_req_free.3http.adoc similarity index 86% rename from docs/man/nng_http_req_free.adoc rename to docs/man/nng_http_req_free.3http.adoc index 8fe0b31c8..7d7b2a6ac 100644 --- a/docs/man/nng_http_req_free.adoc +++ b/docs/man/nng_http_req_free.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_free(3) += nng_http_req_free(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_req_free - free HTTP request structure == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_req_free(nng_http_req *req); ------------ +---- == DESCRIPTION @@ -38,5 +38,5 @@ None. == SEE ALSO -<>, -<> +<>, +<> diff --git a/docs/man/nng_http_req_get_header.adoc b/docs/man/nng_http_req_get_header.3http.adoc similarity index 76% rename from docs/man/nng_http_req_get_header.adoc rename to docs/man/nng_http_req_get_header.3http.adoc index b8ddafd39..11c5eed62 100644 --- a/docs/man/nng_http_req_get_header.adoc +++ b/docs/man/nng_http_req_get_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_get_header(3) += nng_http_req_get_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_req_get_header - return HTTP request header == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_req_get_header(nng_http_req *req, const char *key); ------------ +---- == DESCRIPTION @@ -30,7 +30,8 @@ the request _req_, and returns the associated value if found, or `NULL` if not found. The value of _key_ is case insensitive, and should not include the final -colon in an HTTP header. For example, specifying `Host` or `hOSt` are +colon in an HTTP header. +For example, specifying `Host` or `hOSt` are equivalent, whereas the value `Host:` will not find anything. @@ -44,7 +45,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_get_method.adoc b/docs/man/nng_http_req_get_method.3http.adoc similarity index 74% rename from docs/man/nng_http_req_get_method.adoc rename to docs/man/nng_http_req_get_method.3http.adoc index 2788a39d2..795978a18 100644 --- a/docs/man/nng_http_req_get_method.adoc +++ b/docs/man/nng_http_req_get_method.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_get_method(3) += nng_http_req_get_method(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,17 +16,18 @@ nng_http_req_get_method - return HTTP request method == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_req_get_method(nng_http_req *req); ------------ +---- == DESCRIPTION The `nng_http_req_get_method()` returns the HTTP method associated with -the request _req_. The value will be a string, such as "GET" or "POST". +the request _req_. +The value will be a string, such as "GET" or "POST". == RETURN VALUES @@ -39,6 +40,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_req_get_uri.adoc b/docs/man/nng_http_req_get_uri.3http.adoc similarity index 72% rename from docs/man/nng_http_req_get_uri.adoc rename to docs/man/nng_http_req_get_uri.3http.adoc index a5d7f46a9..446b01122 100644 --- a/docs/man/nng_http_req_get_uri.adoc +++ b/docs/man/nng_http_req_get_uri.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_get_method(3) += nng_http_req_get_method(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,18 +16,19 @@ nng_http_req_get_uri - return HTTP request URI == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_req_get_method(nng_http_req *req); ------------ +---- == DESCRIPTION The `nng_http_req_get_uri()` returns the URI (path) associated with the HTTP -the request _req_. The value returned includes the path, as well as any -query information or fragment. The value will look like a filesystem path +the request _req_. +The value returned includes the path, as well as any query information or +fragment. The value will look like a filesystem path with those optional components appened, such as `/api/get_info.cgi?name=garrett`. == RETURN VALUES @@ -40,6 +41,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_req_get_version.adoc b/docs/man/nng_http_req_get_version.3http.adoc similarity index 81% rename from docs/man/nng_http_req_get_version.adoc rename to docs/man/nng_http_req_get_version.3http.adoc index 958fd2c5f..7bc141906 100644 --- a/docs/man/nng_http_req_get_version.adoc +++ b/docs/man/nng_http_req_get_version.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_get_version(3) += nng_http_req_get_version(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_req_get_version - return HTTP request protocol version == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_req_get_version(nng_http_req *req); ------------ +---- == DESCRIPTION @@ -39,6 +39,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_req_set_data.adoc b/docs/man/nng_http_req_set_data.3http.adoc similarity index 76% rename from docs/man/nng_http_req_set_data.adoc rename to docs/man/nng_http_req_set_data.3http.adoc index 005106a04..e8fb7bd4c 100644 --- a/docs/man/nng_http_req_set_data.adoc +++ b/docs/man/nng_http_req_set_data.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_set_data(3) += nng_http_req_set_data(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -28,7 +28,7 @@ int nng_http_req_set_data(nng_http_req *req, const void *body, size_t size); The `nng_http_req_set_data()` sets the HTTP body associated with the request _req_ to _body_, and the size of the body to _size_. This body data will be automatically sent with the request when it -is sent using <>. +is sent using <>. This also updates the relevant `Content-Length` header of _req_. @@ -40,7 +40,7 @@ until the _req_ is deallocated. TIP: To have a local copy allocated with _req_ that will be automatically deallocated when _req_ is freed, -see <>. +see <>. TIP: It is a good idea to also set the `Content-Type` header. @@ -55,8 +55,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_set_header.adoc b/docs/man/nng_http_req_set_header.3http.adoc similarity index 69% rename from docs/man/nng_http_req_set_header.adoc rename to docs/man/nng_http_req_set_header.3http.adoc index 8d125c4ad..b70e16035 100644 --- a/docs/man/nng_http_req_set_header.adoc +++ b/docs/man/nng_http_req_set_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_set_header(3) += nng_http_req_set_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,25 +16,27 @@ nng_http_req_set_header - set HTTP request header == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_req_set_header(nng_http_req *req, const char *key, const char *val); ------------ +---- == DESCRIPTION The `nng_http_req_set_header()` sets the HTTP header for the request -_req_ and the _key_ to the _val_. The _key_ and _val_ are copied. +_req_ and the _key_ to the _val_. +The _key_ and _val_ are copied. Any previous header with the same _key_ is replaced. -TIP: See <> to +TIP: See <> to add additional headers with the same _key_ without replacing them. The value of _key_ is case insensitive, and should not include the final -colon in an HTTP header. For example, specifying `Host` or `hOSt` are +colon in an HTTP header. +For example, specifying `Host` or `hOSt` are equivalent, whereas the value `Host:` is not a legal header key. == RETURN VALUES @@ -48,8 +50,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_set_method.adoc b/docs/man/nng_http_req_set_method.3http.adoc similarity index 87% rename from docs/man/nng_http_req_set_method.adoc rename to docs/man/nng_http_req_set_method.3http.adoc index 76a6a18df..786cc0714 100644 --- a/docs/man/nng_http_req_set_method.adoc +++ b/docs/man/nng_http_req_set_method.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_set_method(3) += nng_http_req_set_method(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -45,6 +45,6 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_req_set_uri.adoc b/docs/man/nng_http_req_set_uri.3http.adoc similarity index 73% rename from docs/man/nng_http_req_set_uri.adoc rename to docs/man/nng_http_req_set_uri.3http.adoc index 9431b1da3..8a9c3c1e4 100644 --- a/docs/man/nng_http_req_set_uri.adoc +++ b/docs/man/nng_http_req_set_uri.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_set_uri(3) += nng_http_req_set_uri(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,17 +16,18 @@ nng_http_req_set_uri - set HTTP request URI == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_req_set_uri(nng_http_req *req, const char *uri); ------------ +---- == DESCRIPTION The `nng_http_req_set_uri()` sets the Request-URI associated with -the request _req_ to _uri_. The _uri_ should contain precisely the +the request _req_ to _uri_. +The _uri_ should contain precisely the string that will be sent to the HTTP server in the request, including any query information or fragment. @@ -34,8 +35,9 @@ A local copy of the _uri_ is made in the request _req_. NOTE: No validation or canonicalization of the _uri_ is performed. -TIP: The <> function can be used to -perform validation and canonicalization. The `u_requri` member will +TIP: The <> function can be used to +perform validation and canonicalization. +The `u_requri` member will contain a suitable value that can be used with this function. == RETURN VALUES @@ -49,7 +51,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_req_set_version.adoc b/docs/man/nng_http_req_set_version.3http.adoc similarity index 72% rename from docs/man/nng_http_req_set_version.adoc rename to docs/man/nng_http_req_set_version.3http.adoc index 969e8afa9..ae0a5fba1 100644 --- a/docs/man/nng_http_req_set_version.adoc +++ b/docs/man/nng_http_req_set_version.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_req_set_version(3) += nng_http_req_set_version(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -26,17 +26,18 @@ int nng_http_req_set_version(nng_http_req *req, const char *version); == DESCRIPTION The `nng_http_req_set_version()` sets the HTTP protocol version associated with -the request _req_ to _version_. The _version_ must be a string containing -a valid HTTP protocol version, such as "HTTP/1.0". The default value is -"HTTP/1.1". +the request _req_ to _version_. +The _version_ must be a string containing +a valid HTTP protocol version, such as "HTTP/1.0". +The default value is "HTTP/1.1". A local copy of the _version_ is made in the request _req_. NOTE: No validation of the version supplied is performed. NOTE: The library does not contain support for versions of HTTP other than -"HTTP/1.0" and "HTTP/1.1". Specifying any other version may result in -unspecified behavior. +"HTTP/1.0" and "HTTP/1.1". +Specifying any other version may result in unspecified behavior. == RETURN VALUES @@ -50,6 +51,6 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_res_add_header.adoc b/docs/man/nng_http_res_add_header.3http.adoc similarity index 77% rename from docs/man/nng_http_res_add_header.adoc rename to docs/man/nng_http_res_add_header.3http.adoc index 75a4f2064..851331d6b 100644 --- a/docs/man/nng_http_res_add_header.adoc +++ b/docs/man/nng_http_res_add_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_add_header(3) += nng_http_res_add_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,18 +16,19 @@ nng_http_res_add_header - add HTTP response header == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_add_header(nng_http_res *res, const char *key, const char *val); ------------ +---- == DESCRIPTION The `nng_http_res_add_header()` adds an HTTP header for the response -_res_ and the _key_ to the _val_. The _key_ and _val_ are copied. +_res_ and the _key_ to the _val_. +The _key_ and _val_ are copied. If a header with the value of _key_ already exists, then a comma and whitespace separate are appended to it, followed by _val_. @@ -37,7 +38,7 @@ If no such header already exists, then one is created with the value _val_. TIP: The HTTP specification requires that duplicate headers be treated identically to a single header with multiple comma-delimited values. -TIP: See <> if +TIP: See <> if replacement of an existing header rather than appending to it is desired. The value of _key_ is case insensitive, and should not include the final @@ -55,8 +56,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_alloc.3http.adoc b/docs/man/nng_http_res_alloc.3http.adoc new file mode 100644 index 000000000..10638ee7a --- /dev/null +++ b/docs/man/nng_http_res_alloc.3http.adoc @@ -0,0 +1,65 @@ += nng_http_res_alloc(3http) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_http_res_alloc - allocate HTTP response structure + +== SYNOPSIS + +[source, c] +----------- +#include +#include + +int nng_http_res_alloc(nng_http_res **resp); +----------- + +== DESCRIPTION + +The `nng_http_res_alloc()` function allocates a new HTTP response structure +and stores a pointer to it in __resp__. +The response will be initialized +with status code 200 (`NNG_HTTP_STATUS_OK`), and a reason phrase of "OK", +and HTTP protocol version "HTTP/1.1". + +TIP: When an error response is needed, consider using +<> instead. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient free memory exists to allocate a message. +`NNG_ENOTSUP`:: HTTP support not configured. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_alloc.adoc b/docs/man/nng_http_res_alloc.adoc deleted file mode 100644 index 1f4520aaf..000000000 --- a/docs/man/nng_http_res_alloc.adoc +++ /dev/null @@ -1,64 +0,0 @@ -= nng_http_res_alloc(3) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_http_res_alloc - allocate HTTP response structure - -== SYNOPSIS - -[source, c] ------------ -#include -#include - -int nng_http_res_alloc(nng_http_res **resp); ------------ - -== DESCRIPTION - -The `nng_http_res_alloc()` function allocates a new HTTP response structure -and stores a pointer to it in __resp__. The response will be initialized -with status code 200 (`NNG_HTTP_STATUS_OK`), and a reason phrase of "OK", -and HTTP protocol version "HTTP/1.1". - -TIP: When an error response is needed, consider using -<> instead. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -`NNG_ENOMEM`:: Insufficient free memory exists to allocate a message. -`NNG_ENOTSUP`:: HTTP support not configured. - -== SEE ALSO - -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> diff --git a/docs/man/nng_http_res_alloc_error.adoc b/docs/man/nng_http_res_alloc_error.3http.adoc similarity index 65% rename from docs/man/nng_http_res_alloc_error.adoc rename to docs/man/nng_http_res_alloc_error.3http.adoc index 720871b16..e777a6a24 100644 --- a/docs/man/nng_http_res_alloc_error.adoc +++ b/docs/man/nng_http_res_alloc_error.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_alloc_error(3) += nng_http_res_alloc_error(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,22 +16,24 @@ nng_http_res_alloc_error - allocate HTTP error response == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_alloc_error(nng_http_res **resp, uint16_t status); ------------ +---- == DESCRIPTION The `nng_http_res_alloc_error()` function allocates a new HTTP response structure -and stores a pointer to it in __resp__. The response will be initialized +and stores a pointer to it in __resp__. +The response will be initialized with the status code _status_, a corresponding reason phrase, and a simple HTML page containing the same information will be generated and -attached to the response. (Relevant HTTP headers will be set as well, -such as `Content-Type` and `Content-Length`.) The HTTP protocol version -is also set to "HTTP/1.1". +attached to the response. +(Relevant HTTP headers will be set as well, such as `Content-Type` +and `Content-Length`.) +The HTTP protocol version is also set to "HTTP/1.1". TIP: This is the simplest way to generate an error response. @@ -46,9 +48,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_copy_data.adoc b/docs/man/nng_http_res_copy_data.3http.adoc similarity index 67% rename from docs/man/nng_http_res_copy_data.adoc rename to docs/man/nng_http_res_copy_data.3http.adoc index 56d102220..5542c441a 100644 --- a/docs/man/nng_http_res_copy_data.adoc +++ b/docs/man/nng_http_res_copy_data.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_copy_data(3) += nng_http_res_copy_data(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,21 +16,21 @@ nng_http_res_copy_data - copy HTTP response body == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_copy_data(nng_http_res *res, const void *body, size_t size); ------------ +---- == DESCRIPTION The `nng_http_res_copy_data()` makes a copy of _body_ (of size __size__) -and sets the HTTP body for the response _res_ to it. The copy will be -deallocated automatically when _res_ is freed. +and sets the HTTP body for the response _res_ to it. +The copy will be deallocated automatically when _res_ is freed. The copied body data will be automatically sent with the response when it -is sent using <>. +is sent using <>. This also updates the relevant `Content-Length` header of _res_. @@ -38,7 +38,7 @@ NOTE: The current framework does not support sending data via chunked transfer-encoding. TIP: To avoid copying data, the -<> may be used instead. +<> may be used instead. TIP: It is a good idea to also set the `Content-Type` header. @@ -53,8 +53,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_del_header.adoc b/docs/man/nng_http_res_del_header.3http.adoc similarity index 78% rename from docs/man/nng_http_res_del_header.adoc rename to docs/man/nng_http_res_del_header.3http.adoc index 82a2387e9..8d2044478 100644 --- a/docs/man/nng_http_res_del_header.adoc +++ b/docs/man/nng_http_res_del_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_set_header(3) += nng_http_res_set_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_res_set_header - set HTTP response header == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_set_header(nng_http_res *res, const char *key); ------------ +---- == DESCRIPTION @@ -43,8 +43,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_free.adoc b/docs/man/nng_http_res_free.3http.adoc similarity index 86% rename from docs/man/nng_http_res_free.adoc rename to docs/man/nng_http_res_free.3http.adoc index ade3e151f..f3db43141 100644 --- a/docs/man/nng_http_res_free.adoc +++ b/docs/man/nng_http_res_free.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_free(3) += nng_http_res_free(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_res_free - free HTTP response structure == SYNOPSIS [source, c] ------------ +---- #include #include void nng_http_res_free(nng_http_res *req); ------------ +---- == DESCRIPTION @@ -38,5 +38,5 @@ None. == SEE ALSO -<>, -<> +<>, +<> diff --git a/docs/man/nng_http_res_get_header.adoc b/docs/man/nng_http_res_get_header.3http.adoc similarity index 76% rename from docs/man/nng_http_res_get_header.adoc rename to docs/man/nng_http_res_get_header.3http.adoc index 0d3afbd66..43f8b3178 100644 --- a/docs/man/nng_http_res_get_header.adoc +++ b/docs/man/nng_http_res_get_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_get_header(3) += nng_http_res_get_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_res_get_header - return HTTP response header == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_res_get_header(nng_http_res *res, const char *key); ------------ +---- == DESCRIPTION @@ -30,7 +30,8 @@ the response _res_, and returns the associated value if found, or `NULL` if not found. The value of _key_ is case insensitive, and should not include the final -colon in an HTTP header. For example, specifying `Host` or `hOSt` are +colon in an HTTP header. +For example, specifying `Host` or `hOSt` are equivalent, whereas the value `Host:` will not find anything. @@ -44,7 +45,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_get_reason.adoc b/docs/man/nng_http_res_get_reason.3http.adoc similarity index 63% rename from docs/man/nng_http_res_get_reason.adoc rename to docs/man/nng_http_res_get_reason.3http.adoc index 7fe1f079d..053b4cf1d 100644 --- a/docs/man/nng_http_res_get_reason.adoc +++ b/docs/man/nng_http_res_get_reason.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_get_reason(3) += nng_http_res_get_reason(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,19 +16,20 @@ nng_http_res_get_reason - return HTTP response reason == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_res_get_reason(nng_http_res *res); ------------ +---- == DESCRIPTION The `nng_http_res_get_reason()` returns a string representing the "reason -phrase" associated with the response _res_. This is a human-readable -explanation of the status code that would be obtained from -<>. +phrase" associated with the response _res_. +This is a human-readable explanation of the status code that +would be obtained from +<>. == RETURN VALUES @@ -40,7 +41,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_get_status.adoc b/docs/man/nng_http_res_get_status.3http.adoc similarity index 92% rename from docs/man/nng_http_res_get_status.adoc rename to docs/man/nng_http_res_get_status.3http.adoc index 2056e2ce1..f519e659f 100644 --- a/docs/man/nng_http_res_get_status.adoc +++ b/docs/man/nng_http_res_get_status.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_get_status(3) += nng_http_res_get_status(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_res_get_status - return HTTP status code == SYNOPSIS [source, c] ------------ +---- #include #include uint16_t nng_http_res_get_status(nng_http_res *res); ------------ +---- == DESCRIPTION @@ -98,7 +98,7 @@ enum { TIP: When displaying status information to users (or logging such information), consider also including the "reason phrase" obtained with -<>. +<>. == RETURN VALUES @@ -110,7 +110,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_get_version.adoc b/docs/man/nng_http_res_get_version.3http.adoc similarity index 81% rename from docs/man/nng_http_res_get_version.adoc rename to docs/man/nng_http_res_get_version.3http.adoc index 199bd95c2..0b6f76e3e 100644 --- a/docs/man/nng_http_res_get_version.adoc +++ b/docs/man/nng_http_res_get_version.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_get_version(3) += nng_http_res_get_version(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_res_get_version - return HTTP response protocol version == SYNOPSIS [source, c] ------------ +---- #include #include const char *nng_http_res_get_version(nng_http_res *res); ------------ +---- == DESCRIPTION @@ -39,6 +39,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_res_set_data.adoc b/docs/man/nng_http_res_set_data.3http.adoc similarity index 76% rename from docs/man/nng_http_res_set_data.adoc rename to docs/man/nng_http_res_set_data.3http.adoc index aae0d076d..d7ed073bb 100644 --- a/docs/man/nng_http_res_set_data.adoc +++ b/docs/man/nng_http_res_set_data.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_set_data(3) += nng_http_res_set_data(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,19 +16,19 @@ nng_http_res_set_data - set HTTP response body == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_set_data(nng_http_res *res, const void *body, size_t size); ------------ +---- == DESCRIPTION The `nng_http_res_set_data()` sets the HTTP body associated with the response _res_ to _body_, and the size of the body to _size_. This body data will be automatically sent with the response when it -is sent using <>. +is sent using <>. This also updates the relevant `Content-Length` header of _res_. @@ -40,7 +40,7 @@ until the _res_ is deallocated. TIP: To have a local copy allocated with _res_ that will be automatically deallocated when _res_ is freed, -see <>. +see <>. TIP: It is a good idea to also set the `Content-Type` header. @@ -55,8 +55,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_set_header.adoc b/docs/man/nng_http_res_set_header.3http.adoc similarity index 69% rename from docs/man/nng_http_res_set_header.adoc rename to docs/man/nng_http_res_set_header.3http.adoc index 7c2a649e3..7e55b605b 100644 --- a/docs/man/nng_http_res_set_header.adoc +++ b/docs/man/nng_http_res_set_header.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_set_header(3) += nng_http_res_set_header(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,25 +16,27 @@ nng_http_res_set_header - set HTTP response header == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_set_header(nng_http_res *res, const char *key, const char *val); ------------ +---- == DESCRIPTION The `nng_http_res_set_header()` sets the HTTP header for the response -_res_ and the _key_ to the _val_. The _key_ and _val_ are copied. +_res_ and the _key_ to the _val_. +The _key_ and _val_ are copied. Any previous header with the same _key_ is replaced. -TIP: See <> to +TIP: See <> to add additional headers with the same _key_ without replacing them. The value of _key_ is case insensitive, and should not include the final -colon in an HTTP header. For example, specifying `Host` or `hOSt` are +colon in an HTTP header. +For example, specifying `Host` or `hOSt` are equivalent, whereas the value `Host:` is not a legal header key. == RETURN VALUES @@ -48,8 +50,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_set_reason.adoc b/docs/man/nng_http_res_set_reason.3http.adoc similarity index 80% rename from docs/man/nng_http_res_set_reason.adoc rename to docs/man/nng_http_res_set_reason.3http.adoc index 150b81665..096be3939 100644 --- a/docs/man/nng_http_res_set_reason.adoc +++ b/docs/man/nng_http_res_set_reason.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_set_reason(3) += nng_http_res_set_reason(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_res_set_reason - set HTTP response reason == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_set_reason(nng_http_res *res, const char *reason); ------------ +---- == DESCRIPTION @@ -30,7 +30,7 @@ associated with the response _res_ to _reason_. If the value of _reason_ is `NULL` (the default), then a default reason phrase is supplied based upon the value of the status code (see -<>). +<>). TIP: The _reason_ is never parsed automatically, but it can be a hint for humans to help them understand the nature of any erroroneous result. @@ -48,7 +48,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_set_status.adoc b/docs/man/nng_http_res_set_status.3http.adoc similarity index 89% rename from docs/man/nng_http_res_set_status.adoc rename to docs/man/nng_http_res_set_status.3http.adoc index f5e45cc46..241497350 100644 --- a/docs/man/nng_http_res_set_status.adoc +++ b/docs/man/nng_http_res_set_status.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_set_status(3) += nng_http_res_set_status(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,18 +16,18 @@ nng_http_res_set_status - set HTTP response status == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_set_status(nng_http_res *res, uint16_t status); ------------ +---- == DESCRIPTION The `nng_http_res_set_status()` sets the numeric HTTP status code -associated with the response _res_ to _status_. The default value -for a newly allocated response is 200 (`NNG_HTTP_STATUS_OK`). +associated with the response _res_ to _status_. +The default value for a newly allocated response is 200 (`NNG_HTTP_STATUS_OK`). The _status_ is not verified, so the caller should take care to ensure that only a valid code is supplied. @@ -103,8 +103,8 @@ Please see the relevant HTTP RFCs for the semantics and correct use of these status codes. TIP: It is a good idea to also set the "reason phrase" with -<>. This -will help any humans who may have to diagnose any failure. +<>. +This will help any humans who may have to diagnose any failure. == RETURN VALUES @@ -116,7 +116,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_res_set_version.adoc b/docs/man/nng_http_res_set_version.3http.adoc similarity index 72% rename from docs/man/nng_http_res_set_version.adoc rename to docs/man/nng_http_res_set_version.3http.adoc index cb8f29a72..48998c5eb 100644 --- a/docs/man/nng_http_res_set_version.adoc +++ b/docs/man/nng_http_res_set_version.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_res_set_version(3) += nng_http_res_set_version(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,27 +16,28 @@ nng_http_res_set_version - set HTTP response protocol version == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_res_set_version(nng_http_res *res, const char *version); ------------ +---- == DESCRIPTION The `nng_http_res_set_version()` sets the HTTP protocol version associated with -the response _res_ to _version_. The _version_ must be a string containing -a valid HTTP protocol version, such as "HTTP/1.0". The default value is -"HTTP/1.1". +the response _res_ to _version_. +The _version_ must be a string containing +a valid HTTP protocol version, such as "HTTP/1.0". +The default value is "HTTP/1.1". A local copy of the _version_ is made in the response _res_. NOTE: No validation of the version supplied is performed. NOTE: The library does not contain support for versions of HTTP other than -"HTTP/1.0" and "HTTP/1.1". Specifying any other version may result in -unspecified behavior. +"HTTP/1.0" and "HTTP/1.1". +Specifying any other version may result in unspecified behavior. == RETURN VALUES @@ -50,6 +51,6 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_server_add_handler.adoc b/docs/man/nng_http_server_add_handler.3http.adoc similarity index 77% rename from docs/man/nng_http_server_add_handler.adoc rename to docs/man/nng_http_server_add_handler.3http.adoc index 333187a7a..489489b1f 100644 --- a/docs/man/nng_http_server_add_handler.adoc +++ b/docs/man/nng_http_server_add_handler.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_add_handler(3) += nng_http_server_add_handler(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_server_add_handler - add HTTP server handler == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_server_add_handler(nng_http_server *s, nng_http_handler *h); ------------ +---- == DESCRIPTION @@ -35,7 +35,7 @@ If a handler is added to a server, and the server is subsequently deallocated, the handler and any of its resources will also be deallocated. Handlers that are added to a server may be subsequently removed using the -<> function. +<> function. == RETURN VALUES @@ -50,8 +50,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_server_del_handler.adoc b/docs/man/nng_http_server_del_handler.3http.adoc similarity index 76% rename from docs/man/nng_http_server_del_handler.adoc rename to docs/man/nng_http_server_del_handler.3http.adoc index 6dd72d8a2..868ff73e5 100644 --- a/docs/man/nng_http_server_del_handler.adoc +++ b/docs/man/nng_http_server_del_handler.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_del_handler(3) += nng_http_server_del_handler(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_server_del_handler - delete HTTP server handler == SYNOPSIS [source, c] ------------ +---- #include #include -int nng_http_server_del_hanlder(nng_http_server *s, nng_http_handler *h); ------------ +int nng_http_server_del_handler(nng_http_server *s, nng_http_handler *h); +---- == DESCRIPTION @@ -42,7 +42,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_server_get_tls.adoc b/docs/man/nng_http_server_get_tls.3http.adoc similarity index 75% rename from docs/man/nng_http_server_get_tls.adoc rename to docs/man/nng_http_server_get_tls.3http.adoc index c19fb4d9d..28986b932 100644 --- a/docs/man/nng_http_server_get_tls.adoc +++ b/docs/man/nng_http_server_get_tls.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_get_tls(3) += nng_http_server_get_tls(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_server_get_tls - get HTTP server TLS configuration == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_server_get_tls(nng_http_server *s, nng_tls_config **cfgp); ------------ +---- == DESCRIPTION @@ -42,9 +42,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_server_hold.adoc b/docs/man/nng_http_server_hold.3http.adoc similarity index 63% rename from docs/man/nng_http_server_hold.adoc rename to docs/man/nng_http_server_hold.3http.adoc index 61e5b068c..70929c92b 100644 --- a/docs/man/nng_http_server_hold.adoc +++ b/docs/man/nng_http_server_hold.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_hold(3) += nng_http_server_hold(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_server_hold - get and hold HTTP server instance == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_server_hold(nng_http_server **serverp, const nng_url *url); ------------ +---- == DESCRIPTION @@ -30,18 +30,20 @@ for use in serving the URL identified by _url_, and stores a pointer to it at the location pointed to by _serverp_. This function first looks to see if an existing HTTP server instance exists, -that is suitable for this. If so, it increments the reference count on it -and uses that. Otherwise, it will attempt to create a new server instance +that is suitable for this. +If so, it increments the reference count on it and uses that. +Otherwise, it will attempt to create a new server instance with an initial reference count of one (1). The server instance is not started, and can have additional configuration applied to it before it is later started with -<>. +<>. NOTE: The URL matching logic in determining servers is unable to distinguish -between different aliases for the same local IP address. This may create -problems when using URLs for virtual hosting. It is recommended to use -canonical IP addresses or names in the _url_ to avoid confusion. +between different aliases for the same local IP address. +This may create problems when using URLs for virtual hosting. +It is recommended to use canonical IP addresses or names in the +_url_ to avoid confusion. == RETURN VALUES @@ -54,9 +56,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> -<>, -<> +<>, +<>, +<>, +<> +<>, +<> diff --git a/docs/man/nng_http_server_release.adoc b/docs/man/nng_http_server_release.3http.adoc similarity index 79% rename from docs/man/nng_http_server_release.adoc rename to docs/man/nng_http_server_release.3http.adoc index 16c282276..b17e44af6 100644 --- a/docs/man/nng_http_server_release.adoc +++ b/docs/man/nng_http_server_release.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_release(3) += nng_http_server_release(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -27,14 +27,14 @@ void nng_http_server_release(nng_http_server *server); The `nng_http_server_release()` releases an instance of an HTTP _server_ that was previously held with -<>. +<>. This effectively drops the reference count on the server instance. When the reference count drops to zero, then the _server_ and all resources associated with it (e.g. HTTP handlers, connections, etc.) are deallocated. (If the server is "running" when this occurs, then the server is stopped.) -WARNING: It is an error to release an instance of a server that has +IMPORTANT: It is an error to release an instance of a server that has not previously been held, or to attempt to release an instance more times than it has been held. @@ -48,6 +48,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_http_server_set_tls.adoc b/docs/man/nng_http_server_set_tls.3http.adoc similarity index 65% rename from docs/man/nng_http_server_set_tls.adoc rename to docs/man/nng_http_server_set_tls.3http.adoc index 50039e494..2b200653d 100644 --- a/docs/man/nng_http_server_set_tls.adoc +++ b/docs/man/nng_http_server_set_tls.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_set_tls(3) += nng_http_server_set_tls(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_server_set_tls - set HTTP server TLS configuration == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_server_set_tls(nng_http_server *s, nng_tls_config *cfg); ------------ +---- == DESCRIPTION @@ -30,15 +30,15 @@ _cfg_. This change overwrites any previous TLS configuration. -WARNING: This also invalidates any previously obtained values from -<>. +IMPORTANT: This also invalidates any previously obtained values from +<>. If the server is already running (i.e. it has been started with -<>) then this will +<>) then this will fail with `NNG_EBUSY`. TIP: Generally, the _cfg_ must have a configured private key, set with -<> or similar. +<> or similar. == RETURN VALUES @@ -52,9 +52,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_http_server_start.adoc b/docs/man/nng_http_server_start.3http.adoc similarity index 77% rename from docs/man/nng_http_server_start.adoc rename to docs/man/nng_http_server_start.3http.adoc index 4b7b1a4fb..7a631f67e 100644 --- a/docs/man/nng_http_server_start.adoc +++ b/docs/man/nng_http_server_start.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_start(3) += nng_http_server_start(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_http_server_start - start HTTP server == SYNOPSIS [source, c] ------------ +---- #include #include int nng_http_server_start(nng_http_server *server); ------------ +---- == DESCRIPTION @@ -42,9 +42,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> -<>, -<> +<>, +<>, +<>, +<> +<>, +<> diff --git a/docs/man/nng_http_server_stop.adoc b/docs/man/nng_http_server_stop.3http.adoc similarity index 83% rename from docs/man/nng_http_server_stop.adoc rename to docs/man/nng_http_server_stop.3http.adoc index 8b2e08841..ccb926f45 100644 --- a/docs/man/nng_http_server_stop.adoc +++ b/docs/man/nng_http_server_stop.3http.adoc @@ -1,4 +1,4 @@ -= nng_http_server_stop(3) += nng_http_server_stop(3http) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -39,6 +39,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_inproc.adoc b/docs/man/nng_inproc.7.adoc similarity index 55% rename from docs/man/nng_inproc.adoc rename to docs/man/nng_inproc.7.adoc index 5123c3a37..363ad705b 100644 --- a/docs/man/nng_inproc.adoc +++ b/docs/man/nng_inproc.7.adoc @@ -11,21 +11,24 @@ == NAME -nng_inproc - intra-process transport for nng +nng_inproc - intra-process transport == SYNOPSIS [source,c] ----------- +---- #include int nng_inproc_register(void); ----------- +---- == DESCRIPTION -The _nng_inproc_ transport provides communication support between -_nng_ sockets within the same process. This may be used as an alternative +(((transport, _inproc_))) +(((intra-process))) +The ((_inproc_ transport)) provides communication support between +_nng_ sockets within the same process. +This may be used as an alternative to slower transports when data must be moved within the same process. This transport tries hard to avoid copying data, and thus is very @@ -37,7 +40,7 @@ The _inproc_ transport is generally built-in to the _nng_ core, so no extra steps to use it should be necessary. === URI Format - +(((URI, `inproc://`))) This transport uses URIs using the scheme `inproc://`, followed by an arbitrary string of text, terminated by a `NUL` byte. @@ -50,30 +53,9 @@ that URI. === Socket Address -When using an `nng_sockaddr` structure, the actual structure is of type -`struct nng_sockaddr_inproc`. -This type has the following definition: - -[source,c] --------- -#define NNG_AF_INPROC 1 <1> -#define NNG_MAXADDRLEN 128 - -typedef nng_sockaddr_inproc { - // <2> - uint16_t sa_family; // must be NNG_AF_INPROC - char sa_name[NNG_MAXADDRLEN]; // arbitrary "name" - // -} nng_sockaddr_inproc; --------- -<1> The values of these macros may change, so applications -should avoid depending upon their values and instead use them symbolically. -<2> Other members may be present, but only those listed here -are suitable for application use. - -The `sa_family` member will have the value `NNG_AF_INPROC`. -The `sa_path` member is an ASCIIZ string, and may contain any characters, -terminated by a `NUL` byte. +When using an <> structure, +the actual structure is of type +<>. === Transport Options @@ -81,4 +63,6 @@ The _inproc_ transport has no special options. == SEE ALSO -<> +<>, +<>, +<> diff --git a/docs/man/nng_inproc_register.3.adoc b/docs/man/nng_inproc_register.3.adoc new file mode 100644 index 000000000..eee8523c2 --- /dev/null +++ b/docs/man/nng_inproc_register.3.adoc @@ -0,0 +1,42 @@ += nng_inproc_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_inproc_register - register inproc transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_inproc_register(void); +---- + +== DESCRIPTION + +The `nng_inproc_register()` function registers the +((_inproc_ transport))(((transport, _inproc_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_iov.5.adoc b/docs/man/nng_iov.5.adoc new file mode 100644 index 000000000..63d8b03b9 --- /dev/null +++ b/docs/man/nng_iov.5.adoc @@ -0,0 +1,54 @@ += nng_sockaddr_in(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_iov - scatter/gather element + +== SYNOPSIS + +[source, c] +---- +#include + +typedef struct { + void * iov_buf; + size_t iov_len; +} nng_iov; +---- + +== DESCRIPTION + +An `nng_iov` structure represents a single element in a ((scatter/gather)) +array. +Some operations can use arrays of these to access different regions of +memory in a single operation. +For example, it may be useful to send a message with header data from +one part of memory, and a user payload from another. + +The operations that do this typically store an array of these in +an <> structure using the +<> function. + +The following structure members are present: + +`iov_buf`:: + This is a pointer to the first byte within the memory being + referenced by this scatter/gather element. + +`iov_len`:: + This is the size in bytes of this scatter/gather element. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_ipc.7.adoc b/docs/man/nng_ipc.7.adoc new file mode 100644 index 000000000..ee89b29a9 --- /dev/null +++ b/docs/man/nng_ipc.7.adoc @@ -0,0 +1,73 @@ += nng_ipc(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_ipc - IPC transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_ipc_register(void); +---- + +== DESCRIPTION + +(((IPC)))(((transport, _ipc_))) +The ((_ipc_ transport)) provides communication support between +_nng_ sockets within different processes on the same host. +For POSIX platforms, this is implemented using ((UNIX domain sockets)). +For Windows, this is implemented using Windows ((Named Pipes)). +Other platforms may have different implementation strategies. + +// We need to insert a reference to the nanomsg RFC. + +=== Registration + +The _ipc_ transport is generally built-in to the _nng_ core, so +no extra steps to use it should be necessary. + +=== URI Format + +(((URI, `ipc://`))) +This transport uses URIs using the scheme `ipc://`, followed by +a an absolute path name in the file system where the socket or named pipe +should be created. + +TIP: On Windows, all names are prefixed by `\.\pipe\` and do not +occupy the normal file system. +On POSIX platforms, the path is taken literally, +and is relative to the root directory. + +NOTE: If compatibility with legacy _nanomsg_ applications is required, +then pathnames must not be longer than 122 bytes, including the final +`NUL` byte. +This is because legacy versions of _nanomsg_ cannot express URLs +longer than 128 bytes, including the `ipc://` prefix. + +=== Socket Address + +When using an <> structure, +the actual structure is of type <>. + +=== Transport Options + +The _ipc_ transport has no special options. + +NOTE: Options for security attributes and credentials are planned. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_ipc.adoc b/docs/man/nng_ipc.adoc deleted file mode 100644 index e212cf0f6..000000000 --- a/docs/man/nng_ipc.adoc +++ /dev/null @@ -1,83 +0,0 @@ -= nng_ipc(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_ipc - IPC transport for nng - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_ipc_register(void); ----------- - -== DESCRIPTION - -The _nng_ipc_ transport provides communication support between -_nng_ sockets within different processes on the same host. For POSIX -platforms, this is implemented using UNIX domain sockets. For Windows, -this is implemented using Windows Named Pipes. Other platforms may -have different implementation strategies. - -// We need to insert a reference to the nanomsg RFC. - -=== Registration - -The _ipc_ transport is generally built-in to the _nng_ core, so -no extra steps to use it should be necessary. - -=== URI Format - -This transport uses URIs using the scheme `ipc://`, followed by -a an absolute path name in the file system where the socket or named pipe -should be created. - -TIP: On Windows, all names are prefixed by `\.\pipe\` and do not -occupy the normal file system. On POSIX platforms, the path is -taken literally, and is relative to the root directory. - -=== Socket Address - -When using an `nng_sockaddr` structure, the actual structure is of type -`nng_sockaddr_ipc`. This is a `struct` type with the following definition: - -[source,c] --------- -#define NNG_AF_IPC 2 <1> -#define NNG_MAXADDRLEN 128 - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_IPC - char sa_path[NNG_MAXADDRLEN]; // arbitrary "path" - // ... -} nng_sockaddr_ipc; --------- -<1> The values of these macros may change, so applications -should avoid depending upon their values and instead use them symbolically. -<2> Other members may be present, but only those listed here -are suitable for application use. - -The `sa_family` member will have the value `NNG_AF_IPC`. -The `sa_path` member is an ASCIIZ string, and may contain any legal -path name (platform-dependent), terminated by a `NUL` byte. - -=== Transport Options - -The _ipc_ transport has no special -options.footnote:[Options for security attributes and credentials are planned.] - -== SEE ALSO - -<> diff --git a/docs/man/nng_ipc_register.3.adoc b/docs/man/nng_ipc_register.3.adoc new file mode 100644 index 000000000..f0421f162 --- /dev/null +++ b/docs/man/nng_ipc_register.3.adoc @@ -0,0 +1,42 @@ += nng_ipc_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_ipc_register - register ipc transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_ipc_register(void); +---- + +== DESCRIPTION + +The `nng_ipc_register()` function registers the +((_ipc_ transport))(((transport, _ipc_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_listen.adoc b/docs/man/nng_listen.3.adoc similarity index 56% rename from docs/man/nng_listen.adoc rename to docs/man/nng_listen.3.adoc index 4e403f3fb..60f98155f 100644 --- a/docs/man/nng_listen.adoc +++ b/docs/man/nng_listen.3.adoc @@ -24,27 +24,31 @@ int nng_listen(nng_socket s, const char *url, nng_listener *lp, int flags); == DESCRIPTION -The `nng_listener()` function creates a newly initialized -listener, associated with socket _s_, and configured to listen at the -address specified by _url_. If the value of _lp_ is not `NULL`, then +The `nng_listen()` function creates a newly initialized +<> object, associated with socket _s_, +and configured to listen at the address specified by _url_, and starts it. +If the value of _lp_ is not `NULL`, then the newly created listener is stored at the address indicated by _lp_. -Listeners are used to accept connections initiated by remote dialers. An -incoming connection generally results in a pipe being created and attached -to the socket _s_. Unlike dialers, listeners generally can create many +Listeners are used to accept connections initiated by remote dialers. +An incoming connection generally results in and +<> object being created and attached to the socket _s_. +Unlike dialers, listeners generally can create many pipes, which may be open concurrently. -TIP: While it is convenient to think of listeners as "servers", the relationship -between the listener or dialer is orthogonal to any server or client status -that might be associated with a given protocol. For example, a <> +TIP: While it is convenient to think of listeners as "`servers``", the +relationship between the listener or dialer is orthogonal to any server or +client status that might be associated with a given protocol. +For example, a <> socket might have associated dialers, but might also have associated listeners. It may even have some of each at the same time! -Normally, the act of "binding" to the address indicated by _url_ is done -synchronously, including any necessary name resolution. As a result, -a failure, such as if the address is already in use, will be returned -immediately. However, if the special value `NNG_FLAG_NONBLOCK` is -supplied in _flags_, then this is done asynchronously; furthermore any +Normally, the act of "`binding``" to the address indicated by _url_ is done +synchronously, including any necessary name resolution. +As a result, a failure, such as if the address is already in use, will be +returned immediately. +However, if the special value `NNG_FLAG_NONBLOCK` is supplied in _flags_, +then this is done asynchronously; furthermore any failure to bind will be periodically reattempted in the background. TIP: While `NNG_FLAG_NONBLOCK` can help an application be more resilient, @@ -52,8 +56,8 @@ it also generally makes diagnosing failures somewhat more difficult. Because the listener is started immediately, it is generally not possible to apply extra configuration; if that is needed applications should consider -using <> and -<> instead. +using <> and +<> instead. The created listener will continue to accept new connections, associating their pipes with the socket, until either it or the socket _s_ is closed. @@ -72,9 +76,10 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> -<>, -<>, -<> +<>, +<>, +<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_listener.5.adoc b/docs/man/nng_listener.5.adoc new file mode 100644 index 000000000..6c5d0bd02 --- /dev/null +++ b/docs/man/nng_listener.5.adoc @@ -0,0 +1,64 @@ += nng_listener(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_listener - listener + +== SYNOPSIS + +[source, c] +----------- +#include + +typedef uint32_t nng_listener; +----------- + +== DESCRIPTION + +(((listener))) +An `nng_listener` is a handle to a "`listener`" object, which is responsible for +creating <> objects by accepting incoming connections. +A given listener object may create many pipes at the same time, much like an HTTP +server can have many connections to multiple clients simultaneously. + +Listener objects are created by the +<> +or <> functions, and are always "`owned`" +by a single <>. + +TIP: A given <> may have multiple listener +objects, multiple <> objects, or even some +of both. + +TIP: The client/server relationship described by dialer/listener is +completely orthogonal to any similar relationship in the protocols. +For example, a <> socket may use a dialer +to connect to a listener on an <> socket. +This orthogonality can lead to innovative solutions to otherwise +challenging communications problems. + +Listener objects may be destroyed by the +<> function. +They are also closed when their "`owning`" socket is closed. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_listener_close.adoc b/docs/man/nng_listener_close.3.adoc similarity index 73% rename from docs/man/nng_listener_close.adoc rename to docs/man/nng_listener_close.3.adoc index 396a354de..6ef7b87ac 100644 --- a/docs/man/nng_listener_close.adoc +++ b/docs/man/nng_listener_close.3.adoc @@ -16,11 +16,11 @@ nng_listener_close - close listener == SYNOPSIS [source, c] ------------ +---- #include int nng_listener_close(nng_listener l); ------------ +---- == DESCRIPTION @@ -28,9 +28,10 @@ The `nng_listener_close()` function closes the listener _l_. This also closes any pipes that have been created by the listener. Once this function returns, the listener _l_ and any of its resources -are deallocated. Therefore it is an error to attempt to access _l_ -after this function has returned. (Attempts to do so will result in -`NNG_ECLOSED` errors.) +are deallocated. +Therefore it is an error to attempt to access _l_ +after this function has returned. +(Attempts to do so will result in `NNG_ECLOSED` errors.) Listeners are implicitly closed when the socket they are associated with is closed. @@ -45,8 +46,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<> -<>, -<> +<>, +<>, +<> +<>, +<>, +<> diff --git a/docs/man/nng_listener_create.3.adoc b/docs/man/nng_listener_create.3.adoc new file mode 100644 index 000000000..cd7f80da1 --- /dev/null +++ b/docs/man/nng_listener_create.3.adoc @@ -0,0 +1,75 @@ += nng_listener_create(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_listener_create - create listener + +== SYNOPSIS + +[source, c] +---- +#include + +int nng_listener_create(nng_listener *listenerp, nng_socket s, const char *url); +---- + +== DESCRIPTION + +The `nng_listener_create()` function creates a newly initialized +<> object, associated with socket _s_, +and configured to listen at the address specified by _url_, +and stores a pointer to at the location referenced by _listenerp_. + +Listeners are used to accept connections initiated by remote dialers. +An incoming connection generally results in a pipe being created and attached +to the socket _s_. +Unlike dialers, listeners generally can create many pipes, +which may be open concurrently. + +TIP: While it is convenient to think of listeners as "`servers`", the +relationship between the listener or dialer is orthogonal to any server or +client status that might be associated with a given protocol. +For example, a <> socket might have associated dialers, +but might also have associated listeners. +It may even have some of each at the same time! + +The listener is not started, but may be further configured with +the <> family of +functions. + +Once it is fully configured, the listener may be started using the +<> function. + +TIP: If no specific configuration is required, consider using the +simpler <> function instead. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_EADDRINVAL`:: An invalid _url_ was specified. +`NNG_ECLOSED`:: The socket _s_ is not open. +`NNG_ENOMEM`:: Insufficient memory is available. + +== SEE ALSO + +<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_listener_create.adoc b/docs/man/nng_listener_create.adoc deleted file mode 100644 index 0ddcd685a..000000000 --- a/docs/man/nng_listener_create.adoc +++ /dev/null @@ -1,72 +0,0 @@ -= nng_listener_create(3) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_listener_create - create listener - -== SYNOPSIS - -[source, c] ------------ -#include - -int nng_listener_create(nng_listener *listenerp, nng_socket s, const char *url); ------------ - -== DESCRIPTION - -The `nng_listener_create()` function creates a newly initialized -listener, associated with socket _s_, and configured to listen at the -address specified by _url_, and stores a pointer to at the location -referenced by _listenerp_. - -Listeners are used to accept connections initiated by remote dialers. An -incoming connection generally results in a pipe being created and attached -to the socket _s_. Unlike dialers, listeners generally can create many -pipes, which may be open concurrently. - -TIP: While it is convenient to think of listeners as "servers", the relationship -between the listener or dialer is orthogonal to any server or client status -that might be associated with a given protocol. For example, a <> -socket might have associated dialers, but might also have associated listeners. -It may even have some of each at the same time! - -The listener is not started, but may be further configured with -the <> family of -functions. - -Once it is fully configured, the listener may be started using the -<> function. - -TIP: If no specific configuration is required, consider using the -simpler <> function instead. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -`NNG_EADDRINVAL`:: An invalid _url_ was specified. -`NNG_ECLOSED`:: The socket _s_ is not open. -`NNG_ENOMEM`:: Insufficient memory is available. - -== SEE ALSO - -<> -<>, -<>, -<>, -<>, -<>, -<>, -<> diff --git a/docs/man/nng_listener_getopt.adoc b/docs/man/nng_listener_getopt.3.adoc similarity index 91% rename from docs/man/nng_listener_getopt.adoc rename to docs/man/nng_listener_getopt.3.adoc index b79a45789..fde6cc0d7 100644 --- a/docs/man/nng_listener_getopt.adoc +++ b/docs/man/nng_listener_getopt.3.adoc @@ -16,7 +16,7 @@ nng_listener_getopt - get listener option == SYNOPSIS [source, c] ------------ +---- #include int nng_listener_getopt(nng_listener l, const char *opt, void *val, @@ -31,13 +31,14 @@ int nng_listener_getopt_ptr(nng_listener l, const char *opt, void **ptr); int nng_listener_setopt_size(nng_listener l, const char *opt, size_t *zp); int nng_listener_getopt_uint64(nng_listener l, const char *opt, uint64_t *u64p); ------------ +---- == DESCRIPTION The `nng_listener_getopt()` functions are used to retrieve option values for -the listener _l_. The actual options that may be retrieved in this way -vary, and are documented in the <> manual. +the listener _l_. +The actual options that may be retrieved in this way +vary, and many are documented in <>. Additionally some transport-specific options are documented with the transports themselves. @@ -103,9 +104,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<> -<>, -<>, -<> +<>, +<> +<> +<>, +<>, +<> diff --git a/docs/man/nng_listener_setopt.adoc b/docs/man/nng_listener_setopt.3.adoc similarity index 89% rename from docs/man/nng_listener_setopt.adoc rename to docs/man/nng_listener_setopt.3.adoc index 87244510f..5f95b0991 100644 --- a/docs/man/nng_listener_setopt.adoc +++ b/docs/man/nng_listener_setopt.3.adoc @@ -16,7 +16,7 @@ nng_listener_setopt - set listener option == SYNOPSIS [source, c] ------------ +---- #include int nng_listener_setopt(nng_listener l, const char *opt, const void *val, @@ -33,13 +33,13 @@ int nng_listener_setopt_size(nng_listener l, const char *opt, size_t z); int nng_listener_setopt_string(nng_listener l, const char *opt, const char *str); int nng_listener_setopt_uint64(nng_listener l, const char *opt, uint64_t u64); ------------ +---- == DESCRIPTION The `nng_listener_setopt()` functions are used to configure options for the listener _l_. The actual options that may be configured in this way -vary, and are documented in the <> manual. +vary, and many are documented in <>. Additionally some transport-specific options are documented with the transports themselves. @@ -68,7 +68,7 @@ The fourth form, `nng_listener_setopt_ptr()`, is used to pass a pointer _ptr_ to structured data. The data referenced by _ptr_ is generally managed by other functions. For example, TLS configuration objects -(<>) can be passed this way. +(<>) can be passed this way. Note that this form is somewhat special in that the object is generally not copied, but instead the *pointer* to the object is copied. @@ -102,9 +102,11 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<> -<>, -<>, -<> +<>, +<> +<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_listener_start.adoc b/docs/man/nng_listener_start.3.adoc similarity index 73% rename from docs/man/nng_listener_start.adoc rename to docs/man/nng_listener_start.3.adoc index 42175598c..3edd8093f 100644 --- a/docs/man/nng_listener_start.adoc +++ b/docs/man/nng_listener_start.3.adoc @@ -16,11 +16,11 @@ nng_listener_start - start listener == SYNOPSIS [source, c] ------------ +---- #include int nng_listener_start(nng_listener l, int flags); ------------ +---- == DESCRIPTION @@ -28,13 +28,16 @@ The `nng_listener_start()` function starts the listener _l_. This causes the listener to bind to the address it was created with, and to start accepting connections from remote -dialers. Each new connection results in a pipe, which will be attached -to the listener's socket. +dialers. +Each new connection results in an <> object, +which will be attached to the listener's socket. -Normally, the act of "binding" to it's address is done -synchronously, including any necessary name resolution. As a result, +Normally, the act of "`binding``" to it's address is done +synchronously, including any necessary name resolution. +As a result, a failure, such as if the address is already in use, will be returned -immediately. However, if the special value `NNG_FLAG_NONBLOCK` is +immediately. +However, if the special value `NNG_FLAG_NONBLOCK` is supplied in _flags_, then this is done asynchronously; furthermore any failure to bind will be periodically reattempted in the background. @@ -55,7 +58,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<> -<>, -<> +<>, +<> +<>, +<>, +<> diff --git a/docs/man/nng_msg.5.adoc b/docs/man/nng_msg.5.adoc new file mode 100644 index 000000000..3b26bcf04 --- /dev/null +++ b/docs/man/nng_msg.5.adoc @@ -0,0 +1,70 @@ += nng_msg_alloc(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_msg - message + +== SYNOPSIS + +[source, c] +---- +#include + +typedef struct nng_msg nng_msg; +---- + +== DESCRIPTION + +An `nng_msg` represents a single ((message)) sent between Scalability Protocols +peers. +Messages internally have a ((body)), containining the application supplied +payload, and a ((header)), containing protocol specific routing and similar +related information. + +TIP: Using the message-oriented functions in the <> API is +a good way to reduce the likelihood of data copies and improve application +performance. + +Messages are allocated using the <> +function, and are deallocated using the <> +function. + +In addition there are other functions used to access message contents, +including adding data to either the beginning or end of the message, +automatic data conversion, and removing data from the beginning or end. +These functions are designed to try to avoid copying message contents +by making use of scratch areas at the beginning and end of the message. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient free memory exists to allocate a message. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_alloc.adoc b/docs/man/nng_msg_alloc.3.adoc similarity index 72% rename from docs/man/nng_msg_alloc.adoc rename to docs/man/nng_msg_alloc.3.adoc index 40f315523..72cfb3061 100644 --- a/docs/man/nng_msg_alloc.adoc +++ b/docs/man/nng_msg_alloc.3.adoc @@ -16,11 +16,11 @@ nng_msg_alloc - allocate a message == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_alloc(nng_msg **msgp, size_t size); ------------ +---- == DESCRIPTION @@ -39,12 +39,13 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_append.adoc b/docs/man/nng_msg_append.3.adoc similarity index 73% rename from docs/man/nng_msg_append.adoc rename to docs/man/nng_msg_append.3.adoc index 6bdf689d2..99df49437 100644 --- a/docs/man/nng_msg_append.adoc +++ b/docs/man/nng_msg_append.3.adoc @@ -16,12 +16,13 @@ nng_msg_append, nng_msg_append_u32 - append to message body == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_append(nng_msg *msg, const void *val, size_t size); + int nng_msg_append_u32(nng_msg *msg, uint32_t val32); ------------ +---- == DESCRIPTION @@ -40,13 +41,14 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_body.adoc b/docs/man/nng_msg_body.3.adoc similarity index 53% rename from docs/man/nng_msg_body.adoc rename to docs/man/nng_msg_body.3.adoc index 507c0e0dd..12701b0f2 100644 --- a/docs/man/nng_msg_body.adoc +++ b/docs/man/nng_msg_body.3.adoc @@ -16,11 +16,11 @@ nng_msg_body - return message body == SYNOPSIS [source, c] ------------ +---- #include void *nng_msg_body(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -28,11 +28,14 @@ The `nng_msg_body()` function returns a pointer to the start of the body content of the message _msg_. NOTE: The value returned by this is invalidated by a call to any of the -functions that modify the message itself. Such functions are -<>, <>, -any of the <>, -<>, <>, -or <> variants. +functions that modify the message itself. +Such functions are +<>, +<>, +any of the <>, +<>, +<>, +or <> variants. == RETURN VALUES @@ -44,12 +47,13 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_chop.adoc b/docs/man/nng_msg_chop.3.adoc similarity index 72% rename from docs/man/nng_msg_chop.adoc rename to docs/man/nng_msg_chop.3.adoc index f2acff4bb..41a4bd227 100644 --- a/docs/man/nng_msg_chop.adoc +++ b/docs/man/nng_msg_chop.3.adoc @@ -16,12 +16,13 @@ nng_msg_chop, nng_msg_chop_u32 - remove data from end of message body == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_chop(nng_msg *msg, size_t size); + int nng_msg_chop_u32(nng_msg *msg, uint32_t *val32); ------------ +---- == DESCRIPTION @@ -29,8 +30,7 @@ The `nng_msg_chop()` and `nng_msg_chop_u32()` functions remove data from the end of the body of message _msg_. The first function removes _size_ bytes. The second function removes 4 bytes, and stores them in the value _val32_, -after converting them from network-byte order (big-endian) to native -byte order. +after converting them from network-byte order (big-endian) to native byte order. == RETURN VALUES @@ -42,13 +42,14 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_clear.adoc b/docs/man/nng_msg_clear.3.adoc similarity index 86% rename from docs/man/nng_msg_clear.adoc rename to docs/man/nng_msg_clear.3.adoc index aa6e8e64c..23f940fbd 100644 --- a/docs/man/nng_msg_clear.adoc +++ b/docs/man/nng_msg_clear.3.adoc @@ -16,11 +16,11 @@ nng_msg_clear - clear message body content == SYNOPSIS [source, c] ------------ +---- #include void nng_msg_clear(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -36,6 +36,5 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<> diff --git a/docs/man/nng_msg_dup.adoc b/docs/man/nng_msg_dup.3.adoc similarity index 74% rename from docs/man/nng_msg_dup.adoc rename to docs/man/nng_msg_dup.3.adoc index 426fba299..2018f9c7d 100644 --- a/docs/man/nng_msg_dup.adoc +++ b/docs/man/nng_msg_dup.3.adoc @@ -16,17 +16,18 @@ nng_msg_dup - duplicate a message == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_dup(nng_msg **dup, nng_msg_t *orig); ------------ +---- == DESCRIPTION The `nng_msg_dup()` makes a duplicate of the original message _orig_, and -saves the result in the location pointed by _dup_. The actual message -body and header content is copied, but the duplicate may contain a +saves the result in the location pointed by _dup_. +The actual message body and header content is copied, +but the duplicate may contain a different amount of unused space than the original message. == RETURN VALUES @@ -39,7 +40,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_free.adoc b/docs/man/nng_msg_free.3.adoc similarity index 83% rename from docs/man/nng_msg_free.adoc rename to docs/man/nng_msg_free.3.adoc index dd9c39c69..c329685f6 100644 --- a/docs/man/nng_msg_free.adoc +++ b/docs/man/nng_msg_free.3.adoc @@ -16,11 +16,11 @@ nng_msg_free - free a message == SYNOPSIS [source, c] ------------ +---- #include void nng_msg_free(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -36,6 +36,7 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_get_pipe.adoc b/docs/man/nng_msg_get_pipe.3.adoc similarity index 63% rename from docs/man/nng_msg_get_pipe.adoc rename to docs/man/nng_msg_get_pipe.3.adoc index 403b22a39..4a38c9ff1 100644 --- a/docs/man/nng_msg_get_pipe.adoc +++ b/docs/man/nng_msg_get_pipe.3.adoc @@ -16,15 +16,16 @@ nng_msg_get_pipe - get pipe for message == SYNOPSIS [source, c] ------------ +---- #include nng_pipe nng_msg_get_pipe(nng_msg *msg); ------------ +---- == DESCRIPTION -The `nng_msg_get_pipe()` returns the pipe associated with message _msg_. +The `nng_msg_get_pipe()` returns the <> object +associated with message _msg_. On receive, this is the pipe from which a message was received. On transmit, this would be the pipe that the message should be delivered to, if a specific peer is required. @@ -32,16 +33,18 @@ to, if a specific peer is required. NOTE: Not all protocols support overriding the destination pipe. The most usual use case for this is to obtain information about the peer -from which the message was received. This can be used to provide different -behaviors for different peers, such as a higher level of authentication -for peers located on an untrusted network. -The <> function is useful in this situation. +from which the message was received. +This can be used to provide different behaviors for different peers, such as +a higher level of authentication for peers located on an untrusted network. +The <> function +is useful in this situation. == RETURN VALUES This function returns the pipe associated with this message, which will -be a positive value. If the pipe is non-positive, then that indicates that +be a positive value. +If the pipe is non-positive, then that indicates that no specific pipe is associated with the messsage. == ERRORS @@ -50,7 +53,7 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_header.adoc b/docs/man/nng_msg_header.3.adoc similarity index 66% rename from docs/man/nng_msg_header.adoc rename to docs/man/nng_msg_header.3.adoc index 7d85db5ef..053ea8497 100644 --- a/docs/man/nng_msg_header.adoc +++ b/docs/man/nng_msg_header.3.adoc @@ -16,11 +16,11 @@ nng_msg_header - return message header == SYNOPSIS [source, c] ------------ +---- #include void *nng_msg_header(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -29,8 +29,8 @@ content of the message _msg_. NOTE: The message header contains protocol-specific header content. Most applications should not need to access this content, but it is available -for raw mode sockets (set with the `NNG_OPT_RAW` option -- see -<> for more details.) +for raw mode sockets (set with the +<> option.) NOTE: The value returned by this is invalidated by a call to any of the functions that modify the message or the header content. @@ -45,12 +45,13 @@ None. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_header_append.adoc b/docs/man/nng_msg_header_append.3.adoc similarity index 70% rename from docs/man/nng_msg_header_append.adoc rename to docs/man/nng_msg_header_append.3.adoc index a21da6dc5..922f22b59 100644 --- a/docs/man/nng_msg_header_append.adoc +++ b/docs/man/nng_msg_header_append.3.adoc @@ -16,20 +16,22 @@ nng_msg_header_append, nng_msg_header_append_u32 - append to message header == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_header_append(nng_msg *msg, const void *val, size_t size); + int nng_msg_header_append_u32(nng_msg *msg, uint32_t val32); ------------ +---- == DESCRIPTION The `nng_msg_header_append()` and `nng_msg_header_append_u32()` functions append data to the end of the headers of message _msg_, reallocating it if necessary. -The first function appends _size_ bytes, copying them from _val_. The -second function appends the value _val32_ in network-byte order (big-endian). +The first function appends _size_ bytes, copying them from _val_. +The second function appends the value _val32_ in network-byte order +(big-endian). == RETURN VALUES @@ -42,12 +44,12 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_header_chop.adoc b/docs/man/nng_msg_header_chop.3.adoc similarity index 75% rename from docs/man/nng_msg_header_chop.adoc rename to docs/man/nng_msg_header_chop.3.adoc index f9c9f547c..78625365a 100644 --- a/docs/man/nng_msg_header_chop.adoc +++ b/docs/man/nng_msg_header_chop.3.adoc @@ -16,12 +16,13 @@ nng_msg_header_chop, nng_msg_header_chop_u32 - remove data from end of message h == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_header_chop(nng_msg *msg, size_t size); + int nng_msg_header_chop_u32(nng_msg *msg, uint32_t *val32); ------------ +---- == DESCRIPTION @@ -42,12 +43,12 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_header_clear.adoc b/docs/man/nng_msg_header_clear.3.adoc similarity index 86% rename from docs/man/nng_msg_header_clear.adoc rename to docs/man/nng_msg_header_clear.3.adoc index 03fbdccbc..4402ec401 100644 --- a/docs/man/nng_msg_header_clear.adoc +++ b/docs/man/nng_msg_header_clear.3.adoc @@ -16,11 +16,11 @@ nng_msg_header_clear - clear message header == SYNOPSIS [source, c] ------------ +---- #include void nng_msg_header_clear(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -36,6 +36,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_msg_header_insert.adoc b/docs/man/nng_msg_header_insert.3.adoc similarity index 72% rename from docs/man/nng_msg_header_insert.adoc rename to docs/man/nng_msg_header_insert.3.adoc index e70dede7f..89f74b675 100644 --- a/docs/man/nng_msg_header_insert.adoc +++ b/docs/man/nng_msg_header_insert.3.adoc @@ -16,12 +16,13 @@ nng_msg_header_insert, nng_msg_header_insert_u32 - prepend to message header == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_header_insert(nng_msg *msg, const void *val, size_t size); + int nng_msg_header_insert_u32(nng_msg *msg, uint32_t val32); ------------ +---- == DESCRIPTION @@ -41,13 +42,13 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_header_len.adoc b/docs/man/nng_msg_header_len.3.adoc similarity index 84% rename from docs/man/nng_msg_header_len.adoc rename to docs/man/nng_msg_header_len.3.adoc index 68dfbcff5..825df1bab 100644 --- a/docs/man/nng_msg_header_len.adoc +++ b/docs/man/nng_msg_header_len.3.adoc @@ -16,11 +16,11 @@ nng_msg_header_len - return message header length == SYNOPSIS [source, c] ------------ +---- #include size_t nng_msg_header_len(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -36,6 +36,7 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_header_trim.adoc b/docs/man/nng_msg_header_trim.3.adoc similarity index 74% rename from docs/man/nng_msg_header_trim.adoc rename to docs/man/nng_msg_header_trim.3.adoc index 44496c13f..dae561846 100644 --- a/docs/man/nng_msg_header_trim.adoc +++ b/docs/man/nng_msg_header_trim.3.adoc @@ -16,12 +16,13 @@ nng_msg_header_trim, nng_msg_header_trim_u32 - remove data from start of message == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_header_trim(nng_msg *msg, size_t size); + int nng_msg_header_trim_u32(nng_msg *msg, uint32_t *val32); ------------ +---- == DESCRIPTION @@ -42,12 +43,13 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_insert.adoc b/docs/man/nng_msg_insert.3.adoc similarity index 58% rename from docs/man/nng_msg_insert.adoc rename to docs/man/nng_msg_insert.3.adoc index 2a1f6d128..7955a2fbd 100644 --- a/docs/man/nng_msg_insert.adoc +++ b/docs/man/nng_msg_insert.3.adoc @@ -20,6 +20,7 @@ nng_msg_insert, nng_msg_insert_u32 - prepend to message body #include int nng_msg_insert(nng_msg *msg, const void *val, size_t size); + int nng_msg_insert(nng_msg *msg, uint32_t val32); ----------- @@ -27,13 +28,14 @@ int nng_msg_insert(nng_msg *msg, uint32_t val32); The `nng_msg_insert()` and `nng_msg_insert_u32()` functions prepend data to the front of the body of message _msg_, reallocating it if necessary. -The first function prepends _size_ bytes, copying them from _val_. The -second function prepends the value _val32_ in network-byte order (big-endian). +The first function prepends _size_ bytes, copying them from _val_. +The second function prepends the value _val32_ in network-byte order +(big-endian). -TIP: This function makes use of pre-allocated "headroom" in the message if -available, so it can often avoid performing any reallocation. Applications -should use this instead of reallocating and copying message content themselves, -in order to benefit from this capabilitiy. +TIP: This function makes use of pre-allocated "`headroom`" in the message if +available, so it can often avoid performing any reallocation. +Applications should use this instead of reallocating and copying message +content themselves, in order to benefit from this capabilitiy. == RETURN VALUES @@ -45,13 +47,14 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_len.adoc b/docs/man/nng_msg_len.3.adoc similarity index 84% rename from docs/man/nng_msg_len.adoc rename to docs/man/nng_msg_len.3.adoc index 260be3065..e181aa207 100644 --- a/docs/man/nng_msg_len.adoc +++ b/docs/man/nng_msg_len.3.adoc @@ -16,11 +16,11 @@ nng_msg_len - return message body length == SYNOPSIS [source, c] ------------ +---- #include size_t nng_msg_len(nng_msg *msg); ------------ +---- == DESCRIPTION @@ -36,6 +36,7 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_realloc.adoc b/docs/man/nng_msg_realloc.3.adoc similarity index 61% rename from docs/man/nng_msg_realloc.adoc rename to docs/man/nng_msg_realloc.3.adoc index 47c9540be..59c2a2da1 100644 --- a/docs/man/nng_msg_realloc.adoc +++ b/docs/man/nng_msg_realloc.3.adoc @@ -1,4 +1,4 @@ -= nng_msg_alloc(3) += nng_msg_realloc(3) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -11,28 +11,31 @@ == NAME -nng_msg_alloc - allocate a message +nng_msg_realloc - reallocate a message == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_realloc(nng_msg *msg, size_t size); ------------ +---- == DESCRIPTION The `nng_msg_realloc()` function re-allocates a message so that it has -a body of length _size_. This message attempts to avoid extra allocations, +a body of length _size_. +This message attempts to avoid extra allocations, and will reuse the existing memory when possible. TIP: One way to further reduce message allocations is to allocate a message -larger than needed, then use this function or <> -to reduce the message size to that actually needed. The extra space left +larger than needed, then use this function or +<> to reduce the message size +to that actually needed. +The extra space left over will still be present in the message, so that when the message size -needs to grow due to this function or <> +needs to grow due to this function or <> no actual memory allocations need to take place. NOTE: Pointers to message body and header content obtained prior to this @@ -49,13 +52,14 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_msg_set_pipe.adoc b/docs/man/nng_msg_set_pipe.3.adoc similarity index 71% rename from docs/man/nng_msg_set_pipe.adoc rename to docs/man/nng_msg_set_pipe.3.adoc index 845ca5a24..68ca93051 100644 --- a/docs/man/nng_msg_set_pipe.adoc +++ b/docs/man/nng_msg_set_pipe.3.adoc @@ -16,18 +16,19 @@ nng_msg_set_pipe - set pipe for message == SYNOPSIS [source, c] ------------ +---- #include void nng_msg_set_pipe(nng_msg *msg, nng_pipe p); ------------ +---- == DESCRIPTION The `nng_msg_set_pipe()` sets the pipe associated with message _m_ to _p_. This is most often useful when used with protocols that support directing -a message to a specific peer. For example the <> version -1 protocol can do this when `NNG_OPT__POLYAMOROUS` mode is set. +a message to a specific peer. +For example the <> version +1 protocol can do this when `NNG_OPT_PAIR1_POLY` mode is set. NOTE: Not all protocols support overriding the destination pipe. @@ -41,8 +42,9 @@ None. == SEE ALSO -<>, -<>, -<>, -<> -<>, +<>, +<>, +<>, +<>, +<> + diff --git a/docs/man/nng_msg_trim.adoc b/docs/man/nng_msg_trim.3.adoc similarity index 73% rename from docs/man/nng_msg_trim.adoc rename to docs/man/nng_msg_trim.3.adoc index ff6f8431a..e371ff0a0 100644 --- a/docs/man/nng_msg_trim.adoc +++ b/docs/man/nng_msg_trim.3.adoc @@ -16,12 +16,13 @@ nng_msg_trim, nng_msg_trim_u32 - remove data from start of message body == SYNOPSIS [source, c] ------------ +---- #include int nng_msg_trim(nng_msg *msg, size_t size); + int nng_msg_trim_u32(nng_msg *msg, uint32_t *val32); ------------ +---- == DESCRIPTION @@ -42,13 +43,14 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_options.adoc b/docs/man/nng_options.5.adoc similarity index 80% rename from docs/man/nng_options.adoc rename to docs/man/nng_options.5.adoc index 9546e0dc0..f07194d1c 100644 --- a/docs/man/nng_options.adoc +++ b/docs/man/nng_options.5.adoc @@ -16,7 +16,7 @@ nng_options - socket, dialer, listener, and pipe options == SYNOPSIS [source, c] ------------ +---- #include #define NNG_OPT_SOCKNAME "socket-name" @@ -35,28 +35,29 @@ nng_options - socket, dialer, listener, and pipe options #define NNG_OPT_RECVMAXSZ "recv-size-max" #define NNG_OPT_RECONNMINT "reconnect-time-min" #define NNG_OPT_RECONNMAXT "reconnect-time-max" ------------ +---- == DESCRIPTION This page documents the various standard options that can be set or retrieved on objects in the _nng_ library. -Sockets (<>) use the functions -<> -and <> to set and retrieve option values. +Sockets (<> objects) use the functions +<> +and <> to set and retrieve option values. -Dialers (<>) use the functions -<> and -<> to set and retrieve option values. - -Listeners (<>) use the functions -<> -and <> to set and retrieve option +Dialers (<> objects) use the functions +<> and +<> to set and retrieve option values. -Pipes (<>) can only retrieve option values using -the <> function. +Listeners (<> objects) use the functions +<> +and <> to set and +retrieve option values. + +Pipes (<> objects) can only retrieve option values using +the <> function. In addition to the options listed here, transports and protocols will generally have some of their own options, which will be documented with the transport @@ -75,7 +76,7 @@ description of the option. [[NNG_OPT_LINGER]] ((`NNG_OPT_LINGER`)):: (((lingering))) -(`<>`) +(`<>`) This is the linger time of the socket in milliseconds. When this value is non-zero, then the system will attempt to defer closing until it has undelivered data, or until the specified @@ -87,7 +88,7 @@ of undelivered messages. [[NNG_OPT_LOCADDR]] ((`NNG_OPT_LOCADDR`)):: -(`<>`) +(`<>`) This read-only option may be used on listeners, dialers and connected pipes, and represents the local address used for communication. Not all transports support this option, and some transports may support it @@ -103,14 +104,14 @@ If `true`, the socket is in "`raw`" mode, and if `false` the socket is in "`cooked`" mode. Raw mode sockets generally do not have any protocol-specific semantics applied to them; instead the application is expected to perform such semantics itself. -(For example, in "`cooked`" mode an <> socket would +(For example, in "`cooked`" mode a <> socket would automatically copy message headers from a received message to the corresponding reply, whereas in "`raw`" mode this is not done.) [[NNG_OPT_RECONNMINT]] ((`NNG_OPT_RECONNMINT`)):: (((reconnect time, minimum))) -(`<>`) +(`<>`) This is the minimum amount of time (milliseconds) to wait before attempting to establish a connection after a previous attempt has failed. This can be set on a socket, but it can also be overridden on an individual @@ -121,16 +122,16 @@ The option is irrelevant for listeners. ((`NNG_OPT_RECONNMAXT`)):: (((`NNG_OPT_RECONNMAXT`))) (((reconnect time, maximum))) -(`<>`) +(`<>`) This is the maximum amount of time (milliseconds) to wait before attempting to establish a connection after a previous attempt has failed. If this is non-zero, then the time between successive connection attempts -will start at the value of `<>`, +will start at the value of `NNG_OPT_RECONNMINT`, and grow exponentially, until it reaches this value. If this value is zero, then no exponential backoff between connection attempts is done, and each attempt will wait -the time specified by `<>`. +the time specified by `NNG_OPT_RECONNMINT`. This can be set on a socket, but it can also be overridden on an individual dialer. The option is irrelevant for listeners. @@ -165,14 +166,14 @@ be readable. IMPORTANT: Appplications should never attempt to read or write to the returned file descriptor. Furthermore, applications should not attempt to use the actual socket (of -type <>) with polling functions, +type <>) with polling functions, since it is merely an internal identifier and will not necessarily referency any operting system object or handle. TIP: While this option may help applications integrate into existing polling loops, it is more efficient, and often easier, to use the asynchronous I/O -objects instead. See <>. +objects instead. See <>. [[NNG_OPT_RECVMAXSZ]] ((`NNG_OPT_RECVMAXSZ`)):: @@ -194,14 +195,14 @@ NOTE: Some transports may have further message size restrictions! ((`NNG_OPT_RECVTIMEO`)):: (((receive, timeout))) (((timeout, receive))) -(`<>`) +(`<>`) This is the socket receive timeout in milliseconds. When no message is available for receiving at the socket for this period of time, receive operations will fail with a return value of `NNG_ETIMEDOUT`. [[NNG_OPT_REMADDR]] ((`NNG_OPT_REMADDR`)):: -(`<>`) +(`<>`) This read-only option may be used on dialers and connected pipes, and represents the address of a remote peer. Not all transports support this option. @@ -217,7 +218,7 @@ transport is ready to accept them for delivery. This value must be an integer between 0 and 8192, inclusive. NOTE: Not all protocols support buffering sent messages; -generally multicast protocols like <> will +generally multicast protocols like <> will simply discard messages when they cannot be delivered immediately. [[NNG_OPT_SENDFD]] @@ -241,20 +242,20 @@ the descriptor will *not* be readable. IMPORTANT: Appplications should never attempt to read or write to the returned file descriptor. Furthermore, applications should not attempt to use the actual socket (of -type <>) with polling functions, +type <>) with polling functions, since it is merely an internal identifier and will not necessarily referency any operting system object or handle. TIP: While this option may help applications integrate into existing polling loops, it is more efficient, and often easier, to use the asynchronous I/O -objects instead. See <>. +objects instead. See <>. [[NNG_OPT_SENDTIMEO]] ((`NNG_OPT_SENDTIMEO`)):: (((send, timeout))) (((timeout, send))) -(`<>`) +(`<>`) This is the socket send timeout in milliseconds. When a message cannot be queued for delivery by the socket for this period of time (such as if send buffers are full), the operation will fail with a @@ -274,8 +275,17 @@ The string must fit within 64-bytes, including the terminating (`int`) (((time-to-live))) This is the maximum number of "`hops`" a message may traverse (see -<>). +<>). The intention here is to prevent ((forwarding loops)) in device chains. +When this is supported, it can have a value between 1 and 255, inclusive. + +NOTE: Not all protocols support this option. +Those that do generally have a default value of 8. + +TIP: Each node along a forwarding path may have it's own value for the +maximum time-to-live, and performs its own checks before forwarding a message. +Therefore it is helpful if all nodes in the topology use the same value for +this option. [[NNG_OPT_URL]] ((`NNG_OPT_URL`)):: @@ -290,11 +300,12 @@ NOTE: Some transports will canonify URLs before returning them to the application. == SEE ALSO -[.text-left] -<>, -<>, -<>, -<>, -<>, -<>, -<> + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_pair.adoc b/docs/man/nng_pair.7.adoc similarity index 59% rename from docs/man/nng_pair.adoc rename to docs/man/nng_pair.7.adoc index b826f5fcd..35f711875 100644 --- a/docs/man/nng_pair.adoc +++ b/docs/man/nng_pair.7.adoc @@ -17,26 +17,27 @@ nng_pair - pair protocol .Version 0 [source,c] ----------- +---- #include int nng_pair0_open(nng_socket *s); ----------- +---- .Version 1 [source,c] ----------- +---- #include int nng_pair1_open(nng_socket *s); ----------- +---- == DESCRIPTION -The _nng_pair_ protocol implements a peer-to-peer pattern, where +(((protocol, _pair_))) +The ((_pair_ protocol)) implements a peer-to-peer pattern, where relationships between peers are one-to-one. -Version 1 of this protocol supports an optional _polyamorous_ mode where a +Version 1 of this protocol supports an optional ((_polyamorous_ mode)) where a peer can maintain multiple partnerships. Using this mode requires some additional sophistication in the application. @@ -48,18 +49,21 @@ able to receive the message. NOTE: Even though this mode may appear to be "reliable", because back-pressure prevents discarding messages most of the time, there are topologies involving -_devices_ (see <>) or raw mode sockets where -messages may be discarded. Applications that require reliable delivery -semantics should consider using <> sockets, or -implement their own acknowledgement layer on top of pair sockets. - -In order to avoid head-of-line blocking conditions, _polyamorous_ mode pair +_devices_ (see <>) or raw mode sockets +(see <>) where +messages may be discarded. +Applications that require reliable delivery semantics should consider using +<> sockets, or +implement their own acknowledgement layer on top of _pair_ sockets. + +In order to avoid head-of-line blocking conditions, _polyamorous_ mode _pair_ sockets (version 1 only) discard messages if they are unable to deliver them to a peer. === Protocol Versions -Version 0 is the legacy version of this protocol. It lacks any header +Version 0 is the legacy version of this protocol. +It lacks any header information, and is suitable when building simple one-to-one topologies. TIP: Use version 0 if you need to communicate with other implementations, @@ -67,8 +71,9 @@ including the legacy https://github.com/nanomsg/nanomsg[nanomsg] library or https://github.com/go-mangos/mangos[mangos]. Version 1 of the protocol offers improved protection against loops when -used with <>. It also offers _polyamorous_ -mode for forming multiple partnerships on a single socket. +used with <>. +It also offers _polyamorous_ mode for forming multiple partnerships +on a single socket. NOTE: Version 1 of this protocol is considered experimental at this time. @@ -78,14 +83,15 @@ Normally pair sockets are for one-to-one communication, and a given peer will reject new connections if it already has an active connection to another peer. -In _polyamorous_ mode, which is only available with version 1, a socket can -support many one-to-one connections. In this mode, the application must -choose the remote peer to receive an ougoing message by setting the value -of the pipe ID on the outgoing message using -the <> function. +In ((_polyamorous_ mode)), which is only available with version 1, a socket can +support many one-to-one connections. +In this mode, the application must +choose the remote peer to receive an ougoing message by setting the +<> to use for the outgoing message with +the <> function. -Most often the value of the outgoing pipe ID will be obtained from an incoming -message using the <> function, +Most often the value of the outgoing pipe will be obtained from an incoming +message using the <> function, such as when replying to an incoming message. In order to prevent head-of-line blocking, if the peer on the given pipe @@ -97,25 +103,15 @@ to the sender. The following protocol-specific options are available. -`NNG_OPT_PAIR1_POLY`:: +((`NNG_OPT_PAIR1_POLY`)):: (Version 1 only). This option enables the use of _polyamorous_ mode. The value is read-write, and takes an integer boolean value. The default false value (0) indicates that legacy monogamous mode should be used. -`NNG_OPT_MAXTTL`:: +<>:: - (Version 1 only). Maximum time-to-live. This option is an integer value - between 0 and 255, - inclusive, and is the maximum number of "hops" that a message may - pass through until it is discarded. The default value is 8. A value - of 0 may be used to disable the loop protection, allowing an infinite - number of hops. -+ -TIP: Each node along a forwarding path may have it's own value for the -maximum time-to-live, and performs its own checks before forwarding a message. -Therefore it is helpful if all nodes in the topology use the same value for -this option. + (Version 1 only). Maximum time-to-live. === Protocol Headers @@ -123,10 +119,14 @@ Version 0 of the pair protocol has no protocol-specific headers. Version 1 of the pair protocol uses a single 32-bit unsigned value. The low-order (big-endian) byte of this value contains a "hop" count, and is -used in conjuction with the `NNG_OPT_MAXTTL` option to guard against -device forwarding loops. This value is initialized to 1, and incremented -each time the message is received by a new node. +used in conjuction with the +<> option to guard against +device forwarding loops. +This value is initialized to 1, and incremented each time the message is +received by a new node. == SEE ALSO -<> +<>, +<>, +<> diff --git a/docs/man/nng_pair_open.3.adoc b/docs/man/nng_pair_open.3.adoc new file mode 100644 index 000000000..35bda5e52 --- /dev/null +++ b/docs/man/nng_pair_open.3.adoc @@ -0,0 +1,53 @@ += nng_pair_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_pair_open - create pair socket + +== SYNOPSIS + +.Version 0 +[source,c] +---- +#include + +int nng_pair0_open(nng_socket *s); +---- + +.Version 1 +[source,c] +---- +#include + +int nng_pair1_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_pair0_open()` and `nng_pair1_open()` functions +create a <> version 0 or version 1 +<> and return it at the location pointed to by _s_. + +== RETURN VALUES + +These functions returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_pipe.5.adoc b/docs/man/nng_pipe.5.adoc new file mode 100644 index 000000000..4befd3e8e --- /dev/null +++ b/docs/man/nng_pipe.5.adoc @@ -0,0 +1,57 @@ += nng_pipe(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_pipe - communications pipe + +== SYNOPSIS + +[source, c] +----------- +#include + +typedef uint32_t nng_pipe; +----------- + +== DESCRIPTION + +(((pipe)))(((connection))) +An `nng_pipe` is a handle to a "`pipe`", which can be thought of as a single +connection. +(In most cases this is actually the case -- the pipe is an abstraction for a +single TCP or IPC connection.) +Pipes are associated with either the listener or dialer that created them, +and therefore are also automatically associated with a single socket. + +TIP: Most applications should never concern themselves with individual pipes. +However it is possible to access a pipe when more information about the +source of a message is needed, or when more control is required over +message delivery. + +Pipe objects are created by dialers (<> objects) +and listeners (<> objects), which can be +thought of as "`owning`" the pipe. + +Pipe objects may be destroyed by the +<> function. +They are also closed when their "`owning`" dialer or listener is closed, +or when the remote peer closes the underlying connection. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_pipe_close.3.adoc b/docs/man/nng_pipe_close.3.adoc new file mode 100644 index 000000000..598e143a4 --- /dev/null +++ b/docs/man/nng_pipe_close.3.adoc @@ -0,0 +1,51 @@ += nng_pipe_close(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_pipe_close - close pipe + +== SYNOPSIS + +[source, c] +---- +#include + +int nng_pipe_close(nng_socket s); +---- + +== DESCRIPTION + +The `nng_pipe_close()` function closes the supplied pipe, _p_. +Messages that have been submitted for sending may be flushed or delivered, +depending upon the transport and the setting of the +<> option. + +Further attempts to use the pipe after this call returns will result +in `NNG_ECLOSED`. + +TIP: Pipes are automatically closed when their creator closes, or when the +remote peer closes the underlying connection. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ECLOSED`:: The pipe _p_ is already closed or was never opened. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_pipe_getopt.adoc b/docs/man/nng_pipe_getopt.3.adoc similarity index 55% rename from docs/man/nng_pipe_getopt.adoc rename to docs/man/nng_pipe_getopt.3.adoc index 7642ef02a..598de0536 100644 --- a/docs/man/nng_pipe_getopt.adoc +++ b/docs/man/nng_pipe_getopt.3.adoc @@ -20,75 +20,87 @@ nng_pipe_getopt - get pipe option #include int nng_pipe_getopt(nng_pipe p, const char *opt, void *val, size_t *valszp); + int nng_pipe_getopt_int(nng_pipe p, const char *opt, int *ivalp); + int nng_pipe_getopt_ms(nng_pipe p, const char *opt, nng_duration *durp); + int nng_pipe_getopt_size(nng_pipe p, const char *opt, size_t *zp); + int nng_pipe_getopt_uint64(nng_pipe p, const char *opt, uint64_t *u64p); ----------- == DESCRIPTION The `nng_pipe_getopt()` functions are used to retrieve option values for -the pipe _p_. The actual options that may be retrieved in this way -vary, and are documented in the <> manual. +the <> _p_. +The actual options that may be retrieved in this way +vary, and many are documented in <>. Additionally some transport-specific options are documented with the transports themselves, and some protocol-specific options are documented with the protocol. NOTE: All "options" on a pipe are read-only values, and intended to -facilitate understanding the identity of an associated peer; modification -of options must be done on the listener or dialer using either -<> or -<> +facilitate understanding the identity of an associated peer. +Modification of options must be done on the listener or dialer using either +<> or +<> -Any option that is set on an endpoint will be retrievable from pipes -created by that endpoint. +Any option that is set on a dialer or listener will normally be retrievable +from pipes created by that dialer or listener. In all of these forms, the option _opt_ is retrieved from the pipe _p_. The details of the type, size, and semantics of the option will depend on the actual option, and will be documented with the option itself. -The first form of this function, `nng_pipe_getopt()`, can be used to -retrieve the value of any option. It is untyped. The caller must store -a pointer to a buffer to receive the value in _val_, and the size of the +=== `nng_pipe_getopt()`:: + +This is untyped, and can be used to retrieve the value of any option. +A pointer to a buffer to receive the value in _val_, and the size of the buffer shall be stored at the location referenced by _valszp_. When the function returns, the actual size of the data copied (or that would have been copied if sufficient space were present) is stored at -the location referened by _valszp_. If the caller's buffer is not large -enough to hold the entire object, then the copy is truncated. Therefore -the caller should validate that the returned size in _valszp_ does not -exceed the original buffer size to check for truncation. +the location referened by _valszp_. +If the caller's buffer is not large enough to hold the entire object, +then the copy is truncated. +Therefore the caller should check for trncation by verifying that the +size returned in _valszp_ does not exceed the original buffer size. It is acceptable to pass `NULL` for _val_ if the value in _valszp_ is zero. This can be used to determine the size of the buffer needed to receive the object. -Generally, it will be easier to use one of the typed forms instead. Note -however that no validation that the option is actually of the associated -type is performed, so the caller must take care to use the *correct* typed -form. +TIP: Generally, it will be easier to use one of the typed forms instead. +Note however that no validation that the option is actually of the associated +type is performed, so the caller must take care to use the *correct* typed form. + +=== `nng_pipe_getopt_int()`:: + +This function is for options which take an integer (`int`) or boolean (`bool`). +The value will be stored at _ivalp_. For booleans the value will be eiher 0 +(`false`) or 1 (`true`). + +=== `nng_pipe_getopt_ms()`:: + +This function is used to retrieve time durations +(<> -<>, -<> -<> -<>, -<> +<> +<>, +<> +<> +<>, +<>, +<> diff --git a/docs/man/nng_pub.7.adoc b/docs/man/nng_pub.7.adoc new file mode 100644 index 000000000..6f88115c9 --- /dev/null +++ b/docs/man/nng_pub.7.adoc @@ -0,0 +1,70 @@ += nng_pub(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_pub - publisher protocol + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_pub0_open(nng_socket *s); +---- + +== DESCRIPTION + +(((protocol, _pub_))) +The ((_pub_ protocol)) is one half of a ((publisher))/subscriber pattern. +In this pattern, a publisher sends data, which is broadcast to all +subscribers. +The subscribing applications only see the data to which +they have subscribed. + +The _pub_ protocol is the publisher side, and the +<> protocol is the subscriber side. + +NOTE: In this implementation, the publisher delivers all messages to all +subscribers. +The subscribers maintain their own subscriptions, and filter them locally. +Thus, this pattern should not be used in an attempt to reduce bandwidth +consumption. + +The topics that subscribers subscribe to is just the first part of +the message body. +Applications should construct their messages accordingly. + +=== Socket Operations + +The <> call creates a publisher socket. +This socket may be used to send messages, but is unable to receive them. +Attempts to receive messages will result in `NNG_ENOTSUP`. + +=== Protocol Versions + +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) + +=== Protocol Options + +The _pub_ protocol has no protocol-specific options. + +=== Protocol Headers + +The _pub_ protocol has no protocol-specific headers. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_pub.adoc b/docs/man/nng_pub.adoc deleted file mode 100644 index a8acb2c17..000000000 --- a/docs/man/nng_pub.adoc +++ /dev/null @@ -1,66 +0,0 @@ -= nng_pub(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_pub - publisher protocol - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_pub0_open(nng_socket *s); ----------- - -== DESCRIPTION - -The _nng_pub_ protocol is one half of a publisher/subscriber pattern. -In this pattern, a publisher sends data, which is broadcast to all -subscribers. The subscribing applications only see the data to which -they have subscribed. - -The _nng_pub_ protocol is the publisher side, and the -<> protocol is the subscriber side. - -NOTE: In this implementation, the publisher delivers all messages to all -subscribers. The subscribers maintain their own subscriptions, and filter -them locally. Thus, this pattern should not be used in an attempt to -reduce bandwidth consumption. - -The topics that subscribers subscribe to is just the first part of -the message body. Applications should construct their messages -accordingly. - -=== Socket Operations - -The `nng_pub0_open()` call creates a publisher socket. This socket -may be used to send messages, but is unable to receive them. Attempts -to receive messages will result in `NNG_ENOTSUP`. - -=== Protocol Versions - -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) - -=== Protocol Options - -The _nng_pub_ protocol has no protocol-specific options. - -=== Protocol Headers - -The _nng_pub_ protocol has no protocol-specific headers. - -== SEE ALSO - -<>, -<> diff --git a/docs/man/nng_pub_open.3.adoc b/docs/man/nng_pub_open.3.adoc new file mode 100644 index 000000000..ad46c7401 --- /dev/null +++ b/docs/man/nng_pub_open.3.adoc @@ -0,0 +1,45 @@ += nng_pub_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_pub_open - create pub socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_pub0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_pub0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_pull.adoc b/docs/man/nng_pull.7.adoc similarity index 52% rename from docs/man/nng_pull.adoc rename to docs/man/nng_pull.7.adoc index f56afb5ef..9cc17bca4 100644 --- a/docs/man/nng_pull.adoc +++ b/docs/man/nng_pull.7.adoc @@ -24,40 +24,43 @@ int nng_pull0_open(nng_socket *s); == DESCRIPTION -The _nng_pull_ protocol is one half of a pipeline pattern. The other half -is the <> protocol. +(((protocol, _pull_))) +The ((_pull_ protocol)) is one half of a ((pipeline pattern)). +The other half is the <> protocol. In the pipeline pattern, pushers distribute messages to pullers. Each message sent by a pusher will be sent to one of its peer pullers, chosen in a round-robin fashion from the set of connected peers available for receiving. -This property makes this pattern useful in load-balancing scenarios. +This property makes this pattern useful in ((load-balancing)) scenarios. === Socket Operations -The `nng_pull0_open()` call creates a puller socket. This socket -may be used to receive messages, but is unable to send them. Attempts -to send messages will result in `NNG_ENOTSUP`. +The <> call creates a puller socket. +This socket may be used to receive messages, but is unable to send them. +Attempts to send messages will result in `NNG_ENOTSUP`. -When receiving messages, the _nng_pull_ protocol accepts messages as -they arrive from peers. If two peers both have a message ready, the +When receiving messages, the _pull_ protocol accepts messages as +they arrive from peers. +If two peers both have a message ready, the order in which messages are handled is undefined. === Protocol Versions -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) === Protocol Options -The _nng_pull_ protocol has no protocol-specific options. +The _pull_ protocol has no protocol-specific options. === Protocol Headers -The _nng_pull_ protocol has no protocol-specific headers. +The _pull_ protocol has no protocol-specific headers. == SEE ALSO -<>, -<> +<>, +<>, +<>, diff --git a/docs/man/nng_pull_open.3.adoc b/docs/man/nng_pull_open.3.adoc new file mode 100644 index 000000000..8b4b2389b --- /dev/null +++ b/docs/man/nng_pull_open.3.adoc @@ -0,0 +1,45 @@ += nng_pull_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_pull_open - create pull socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_pull0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_pull0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_push.7.adoc b/docs/man/nng_push.7.adoc new file mode 100644 index 000000000..27ddd925d --- /dev/null +++ b/docs/man/nng_push.7.adoc @@ -0,0 +1,72 @@ += nng_push(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_push - push protocol + +== SYNOPSIS + +[source,c] +---------- +#include + +int nng_push0_open(nng_socket *s); +---------- + +== DESCRIPTION + +(((protocol, _push_))) +The ((_push_ protocol)) is one half of a ((pipeline pattern)). +The other side is the <> protocol. + +In the pipeline pattern, pushers distribute messages to pullers. +Each message sent by a pusher will be sent to one of its peer pullers, +chosen in a round-robin fashion +from the set of connected peers available for receiving. +This property makes this pattern useful in ((load-balancing)) scenarios. + +=== Socket Operations + +The <> call creates a pusher socket. +This socket may be used to send messages, but is unable to receive them. +Attempts to receive messages will result in `NNG_ENOTSUP`. + +Send operations will observe flow control (back-pressure), so that +only peers capable of accepting a message will be considered. +If no peer is available to receive a message, then the send operation will +wait until one is available, or the operation times out. + +NOTE: Although the pipeline protocol honors flow control, and attempts +to avoid dropping messages, no guarantee of delivery is made. +Furthermore, as there is no capability for message acknowledgement, +applications that need reliable delivery are encouraged to consider the +<> protocol instead. + +=== Protocol Versions + +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) + +=== Protocol Options + +The _push_ protocol has no protocol-specific options. + +=== Protocol Headers + +The _push_ protocol has no protocol-specific headers. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_push.adoc b/docs/man/nng_push.adoc deleted file mode 100644 index 42cc2dd55..000000000 --- a/docs/man/nng_push.adoc +++ /dev/null @@ -1,71 +0,0 @@ -= nng_push(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_push - push protocol - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_push0_open(nng_socket *s); ----------- - -== DESCRIPTION - -The _nng_push_ protocol is one half of a pipeline pattern. The -other side is the <> protocol. - -In the pipeline pattern, pushers distribute messages to pullers. -Each message sent -by a pusher will be sent to one of its peer pullers, -chosen in a round-robin fashion -from the set of connected peers available for receiving. -This property makes this pattern useful in load-balancing scenarios. - -=== Socket Operations - -The `nng_push0_open()` call creates a pusher socket. This socket -may be used to send messages, but is unable to receive them. Attempts -to receive messages will result in `NNG_ENOTSUP`. - -Send operations will observe flow control (back-pressure), so that -only peers capable of accepting a message will be considered. If no -peer is available to receive a message, then the send operation will -wait until one is available, or the operation times out. - -NOTE: Although the pipeline protocol honors flow control, and attempts -to avoid dropping messages, no guarantee of delivery is made. Furthermore, -as there is no capability for message acknowledgement, applications that -need reliable delivery are encouraged to consider the -<> protocol instead. - -=== Protocol Versions - -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) - -=== Protocol Options - -The _nng_push_ protocol has no protocol-specific options. - -=== Protocol Headers - -The _nng_push_ protocol has no protocol-specific headers. - -== SEE ALSO - -<>, -<>, -<> diff --git a/docs/man/nng_push_open.3.adoc b/docs/man/nng_push_open.3.adoc new file mode 100644 index 000000000..8470b6322 --- /dev/null +++ b/docs/man/nng_push_open.3.adoc @@ -0,0 +1,45 @@ += nng_push_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_push_open - create push socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_push0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_push0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_recv.adoc b/docs/man/nng_recv.3.adoc similarity index 64% rename from docs/man/nng_recv.adoc rename to docs/man/nng_recv.3.adoc index f9f8f1dd6..47ce4cbe7 100644 --- a/docs/man/nng_recv.adoc +++ b/docs/man/nng_recv.3.adoc @@ -16,11 +16,11 @@ nng_recv - recv data == SYNOPSIS [source, c] ------------ +---- #include int nng_recv(nng_socket s, void *data, size_t *sizep int flags); ------------ +---- == DESCRIPTION @@ -28,28 +28,31 @@ The `nng_recv()` receives a message. If the special flag `NNG_FLAG_ALLOC` is not specified, then the caller must set _data_ to a buffer to receive the message body content, and must store -the size of that buffer at the location pointed to by _sizep_. When the -function returns, if it is successful, the size at _sizep_ will be updated with -the actual message body length copied into _data_. +the size of that buffer at the location pointed to by _sizep_. +When the function returns, if it is successful, the size at _sizep_ will be +updated with the actual message body length copied into _data_. -If the special flag `NNG_FLAG_ALLOC` is present, then a "zero-copy" mode is -used. In this case the caller must set the value of _data_ to the location +If the special flag `NNG_FLAG_ALLOC` is present, then a "`((zero-copy))`" +mode is used. +In this case the caller must set the value of _data_ to the location of another pointer (of type `void *`), and the _sizep_ pointer must be set -to a location to receive the size of the message body. The function will then -allocate a message buffer (as if by <>), fill it with +to a location to receive the size of the message body. +The function will then allocate a message buffer +(as if by <>), fill it with the message body, and store it at the address referenced by _data_, and update -the size referenced by _sizep_. When this flag is present, the caller assumes +the size referenced by _sizep_. +When this flag is present, the caller assumes responsibility for disposing of the received buffer either by the function -<> or reusing the message for sending (with the same -size) via <>. +<> or reusing the message for sending (with the same +size) in a call to <>. NOTE: The semantics of what receiving a message means vary from protocol to -protocol, so examination of the protocol documentation is encouraged. (For -example, with an <> socket a message may only be received -after a request has been sent, and an <> socket +protocol, so examination of the protocol documentation is encouraged. +(For example, with a <> socket a message may only be received +after a request has been sent, and a <> socket may only receive messages corresponding to topics to which it has subscribed.) Furthermore, some protocols may not support receiving data at all, such as -<>. +<>. TIP: The `NNG_FLAG_ALLOC` flag can be used to reduce data copies, thereby increasing performance, particularly if the buffer is reused to send @@ -71,9 +74,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_recv_aio.3.adoc b/docs/man/nng_recv_aio.3.adoc new file mode 100644 index 000000000..7e30996c4 --- /dev/null +++ b/docs/man/nng_recv_aio.3.adoc @@ -0,0 +1,79 @@ += nng_recv_aio(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_recv_aio - receive message asynchronously + +== SYNOPSIS + +[source, c] +---- +#include + +void nng_recv_aio(nng_socket s, nng_aio *aio); +---- + +== DESCRIPTION + +The `nng_recv_aio()` receives a <> using the +<> _s_ asynchronously. + +When a message is successfully received by the socket, it is +stored in the _aio_ by an internal call equivalent to +<>, then the completion +callback on the _aio_ is executed. +In this case, <> will +return zero. +The callback function is responsible for retrieving the message +and disposing of it appropriately. + +IMPORTANT: Failing to accept and dispose of messages in this +case can lead to memory leaks. + +If for some reason the asynchronous receive cannot be completed +successfully (including by being canceled or timing out), then +the callback will still be executed, +but <> will be non-zero. + +NOTE: The semantics of what receiving a message means varies from protocol to +protocol, so examination of the protocol documentation is encouraged. +(For example, with a <> socket the data is broadcast, so that +any peers who have a suitable subscription will be able to receive it using +<> or a similar function.) +Furthermore, some protocols may not support receiving (such as +<>) or may require other conditions. +(For example, <> sockets cannot normally receive data, which +are replies to requests, until they have first sent a request.) + +== RETURN VALUES + +None. (The operation completes asynchronously.) + +== ERRORS + +`NNG_ECANCELED`:: The operation was aborted. +`NNG_ECLOSED`:: The socket _s_ is not open. +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol for socket _s_ does not support receiving. +`NNG_ESTATE`:: The socket _s_ cannot receive data in this state. +`NNG_ETIMEDOUT`:: The receive timeout expired. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_recvmsg.adoc b/docs/man/nng_recvmsg.3.adoc similarity index 75% rename from docs/man/nng_recvmsg.adoc rename to docs/man/nng_recvmsg.3.adoc index 03cc99b24..c2276511b 100644 --- a/docs/man/nng_recvmsg.adoc +++ b/docs/man/nng_recvmsg.3.adoc @@ -28,22 +28,22 @@ The `nng_recvmsg()` receives a message on socket _s_, storing the received message at the location pointed to by _msgp_. TIP: Using this function gives access to the message structure, and thus may -offer more functionality than the simpler <> function. +offer more functionality than the simpler <> function. The _flags_ may contain the following value: `NNG_FLAG_NONBLOCK`:: - The function returns immediately, even if no message is available. Without - this flag, the function will wait until a message is received by the socket - _s_, or any configured timer expires. + The function returns immediately, even if no message is available. + Without this flag, the function will wait until a message is received + by the socket _s_, or any configured timer expires. NOTE: The semantics of what receiving a message means vary from protocol to -protocol, so examination of the protocol documentation is encouraged. (For -example, with an <> socket a message may only be received -after a request has been sent, and an <> socket +protocol, so examination of the protocol documentation is encouraged. +(For example, with an <> socket a message may only be received +after a request has been sent, and an <> socket may only receive messages corresponding to topics to which it has subscribed.) Furthermore, some protocols may not support receiving data at all, such as -<>. +<>. == RETURN VALUES @@ -60,8 +60,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_rep.7.adoc b/docs/man/nng_rep.7.adoc new file mode 100644 index 000000000..7b3635c4b --- /dev/null +++ b/docs/man/nng_rep.7.adoc @@ -0,0 +1,75 @@ += nng_rep(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_rep - reply protocol + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_rep0_open(nng_socket *s); +---- + +== DESCRIPTION + +(((protocol, _rep_))) +The ((_rep_ protocol)) is one half of a ((request/reply pattern)). +In this pattern, a requester sends a message to one replier, who +is expected to reply. +The request is resent if no reply arrives, +until a reply is received or the request times out. + +TIP: This protocol is useful in setting up RPC-like services. +It is also "`reliable`", in that a the requester will keep retrying until +a reply is received. + +The _rep_ protocol is the replier side, and the +<> protocol is the requester side. + +=== Socket Operations + +The <> call creates a replier socket. +This socket may be used to receive messages (requests), and then to send +replies. +Generally a reply can only be sent after receiving a request. +(Attempts to receive a message will result in `NNG_ESTATE` if there +is no outstanding request.) + +Attempts to send on a socket with no outstanding requests will result +in `NNG_ESTATE`. + +Raw mode sockets (set with <>) +ignore all these restrictions. + +=== Protocol Versions + +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) + +==== Protocol Options + +The _rep_ protocol has no protocol-specific options. + +==== Protocol Headers + +(((backtrace))) +The _rep_ protocol uses a _backtrace_ in the header. +This is more fully documented in the <> manual. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_rep.adoc b/docs/man/nng_rep.adoc deleted file mode 100644 index dcc7e6fbc..000000000 --- a/docs/man/nng_rep.adoc +++ /dev/null @@ -1,83 +0,0 @@ -= nng_rep(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -NAME ----- -nng_rep - reply protocol - -SYNOPSIS --------- - -[source,c] ----------- -#include - -int nng_rep0_open(nng_socket *s); ----------- - -DESCRIPTION ------------ - -The _nng_rep_ protocol is one half of a request/reply pattern. -In this pattern, a requester sends a message to one replier, who -is expected to reply. The request is resent if no reply arrives, -until a reply is received or the request times out. - -TIP: This protocol is useful in setting up RPC-like services. It -is also "reliable", in that a the requester will keep retrying until -a reply is received. - -The _nng_rep_ protocol is the replier side, and the -<> protocol is the requester side. - -Socket Operations -~~~~~~~~~~~~~~~~~ - -The `nng_rep0_open()` call creates a requester socket. This socket -may be used to receive messages (requests), and then to send replies. Generally -a reply can only be sent after receiving a request. (Attempts to receive -a message will result in `NNG_ESTATE` if there is no outstanding request.) - -Attempts to send on a socket with no outstanding requests will result -in `NNG_ESTATE`. - -Raw mode sockets (set with `NNG_OPT_RAW`) ignore all these restrictions. - -Protocol Versions -~~~~~~~~~~~~~~~~~ - -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) - -Protocol Options -~~~~~~~~~~~~~~~~ - -The following protocol-specific options are available. - -`NNG_OPT_MAXTTL`:: - - Maximum time-to-live. This option is an integer value - between 0 and 255, - inclusive, and is the maximum number of "hops" that a message may - pass through until it is discarded. The default value is 8. A value - of 0 may be used to disable the loop protection, allowing an infinite - number of hops. - -Protocol Headers -~~~~~~~~~~~~~~~~ - -The _nng_rep_ protocol uses a _backtrace_ in the header. This is -more fully documented in the <> manual. - -SEE ALSO --------- -<>, -<> diff --git a/docs/man/nng_rep_open.3.adoc b/docs/man/nng_rep_open.3.adoc new file mode 100644 index 000000000..4be697bb5 --- /dev/null +++ b/docs/man/nng_rep_open.3.adoc @@ -0,0 +1,45 @@ += nng_rep_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_rep_open - create rep socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_rep0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_rep0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_req.adoc b/docs/man/nng_req.7.adoc similarity index 54% rename from docs/man/nng_req.adoc rename to docs/man/nng_req.7.adoc index 550c90c4a..9d93eade0 100644 --- a/docs/man/nng_req.adoc +++ b/docs/man/nng_req.7.adoc @@ -24,39 +24,45 @@ int nng_req0_open(nng_socket *s); == DESCRIPTION -The _nng_req_ protocol is one half of a request/reply pattern. +(((protocol, _req_))) +The ((_req_ protocol)) is one half of a ((request/reply pattern)). In this pattern, a requester sends a message to one replier, who -is expected to reply. The request is resent if no reply arrives, +is expected to reply. +The request is resent if no reply arrives, until a reply is received or the request times out. -TIP: This protocol is useful in setting up RPC-like services. It -is also "reliable", in that a the requester will keep retrying until +TIP: This protocol is useful in setting up RPC-like services. +It is also "reliable", in that a the requester will keep retrying until a reply is received. -NOTE: Because requests are resent, it is important that they be idempotent +NOTE: Because requests are resent, it is important that they be ((idempotent)) to ensure predictable and repeatable behavior even in the face of duplicated requests, which can occur (for example if a reply message is lost for some reason.) +(((load-balancing))) The requester generally only has one outstanding request at a time unless -in "raw" mode (via `NNG_OPT_RAW`), and it will generally attempt to spread -work requests to different peer repliers. +in "raw" mode (via +<>), +and it will generally attempt to spread work requests to different peer repliers. -TIP: This property, when combined with a <> can -help provide a degree of load-balancing. +TIP: This property, when combined with <> +can help provide a degree of load-balancing. -The _nng_req_ protocol is the requester side, and the -<> protocol is the replier side. +The _req_ protocol is the requester side, and the +<> protocol is the replier side. === Socket Operations -The `nng_req0_open()` call creates a requester socket. This socket -may be used to send messages (requests), and then to receive replies. Generally -a reply can only be received after sending a request. (Attempts to receive -a message will result in `NNG_ESTATE` if there is no outstanding request.) +The <> call creates a requester socket. +This socket may be used to send messages (requests), +and then to receive replies. +Generally a reply can only be received after sending a request. +(Attempts to receive a message will result in `NNG_ESTATE` if there is no +outstanding request.) -Requests may be canceled by sending a different request. This will -cause the requester to discard any reply from the earlier request, +Requests may be canceled by sending a different request. +This will cause the requester to discard any reply from the earlier request, but it will not stop a replier from processing a request it has already received or terminate a request that has already been placed on the wire. @@ -64,18 +70,19 @@ that has already been placed on the wire. Attempts to receive on a socket with no outstanding requests will result in `NNG_ESTATE`. -Raw mode sockets (set with `NNG_OPT_RAW`) ignore all these restrictions. +Raw mode sockets (set with <>) +ignore all these restrictions. === Protocol Versions -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) === Protocol Options -The following protocol-specific options are available. +The following protocol-specific option is available. -`NNG_OPT_REQ_RESENDTIME`:: +((`NNG_OPT_REQ_RESENDTIME`)):: This read/write option is a duration (32-bit unsigned integer) representing a relative number of milliseconds. @@ -85,35 +92,29 @@ The following protocol-specific options are available. the original request was sent disconnects, or if a peer becomes available while the requester is waiting for an available peer.) -`NNG_OPT_MAXTTL`:: - - Maximum time-to-live. This option is an integer value - between 0 and 255, - inclusive, and is the maximum number of "hops" that a message may - pass through until it is discarded. The default value is 8. A value - of 0 may be used to disable the loop protection, allowing an infinite - number of hops. - === Protocol Headers -This protocol uses a _backtrace_ in the header. This -form uses a "stack" of 32-bit big-endian identifiers. There *must* be -at least one identifier, the __request ID__, which will be the last -element in the array, and *must* have the most significant bit set. +(((backtrace))) +This protocol uses a _backtrace_ in the header. +This form uses a "stack" of 32-bit big-endian identifiers. +There *must* be at least one identifier, the __request ID__, which will be the +last element in the array, and *must* have the most significant bit set. -There may be additional __peer ID__s preceeding the request ID. These -will be distinguishable from the request ID by having their most +There may be additional __peer ID__s preceeding the request ID. +These will be distinguishable from the request ID by having their most significant bit clear. When a request message is received by a forwarding node (see -<>), the forwarding node prepends a +<>), the forwarding node prepends a 32-bit peer ID (which *must* have the most significant bit clear), which is the forwarder's way of identifying the directly connected -peer from which it received the message. (This peer ID, except for the +peer from which it received the message. +(This peer ID, except for the most significant bit, has meaning only to the forwarding node itself.) It may help to think of prepending a peer ID as "pushing" a peer ID onto the -front of the stack of headers for the message. (It will use the peer ID +front of the stack of headers for the message. +(It will use the peer ID it popped from the front to determine the next intermediate destination for the reply.) @@ -131,6 +132,7 @@ request ID it originally used for the request. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_req_open.3.adoc b/docs/man/nng_req_open.3.adoc new file mode 100644 index 000000000..638ef43af --- /dev/null +++ b/docs/man/nng_req_open.3.adoc @@ -0,0 +1,45 @@ += nng_req_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_req_open - create rep socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_req0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_req0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_respondent.7.adoc b/docs/man/nng_respondent.7.adoc new file mode 100644 index 000000000..1235941a3 --- /dev/null +++ b/docs/man/nng_respondent.7.adoc @@ -0,0 +1,79 @@ += nng_respondent(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_respondent - respondent protocol + +== SYNOPSIS + +[source,c] +---------- +#include + +int nng_respondent0_open(nng_socket *s); +---------- + +== DESCRIPTION + +(((protocol, _respondent_))) +The ((_respondent_ protocol)) is one half of a ((survey pattern)). +In this pattern, a surveyor sends a survey, which is broadcast to all +peer respondents. +The respondents then have a chance to reply (but are not obliged to reply). +The survey itself is a timed event, so that responses +received after the survey has finished are discarded. + +TIP: This protocol is useful in solving voting problems, such as leader +election in cluster configurations, as well as certain kinds of service +discovery problems. + +The _respondent_ protocol is the respondent side, and the +<> protocol is the surveyor side. + +=== Socket Operations + +The <> call creates a +respondent socket. +This socket may be used to receive messages, and then to send replies. +A reply can only be sent after receiving a survey, and generally the +reply will be sent to surveyor from whom the last survey was received. + +Respondents may discard a survey by simply not replying to it. + +Raw mode sockets (set with <>) +ignore all these restrictions. + +=== Protocol Versions + +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined. +An earlier and incompatible version of the protocol was used in older +pre-releases of http://nanomsg.org[nanomsg], but was not released in any +production version.) + +=== Protocol Options + +The _respondent_ protocol has no protocol-specific options. + +=== Protocol Headers + +(((backtrace))) +The _respondent_ protocol uses a _backtrace_ in the header. +This is more fully documented in the <> manual. + +// TODO: Insert reference to RFC. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_respondent.adoc b/docs/man/nng_respondent.adoc deleted file mode 100644 index 9cc6519e3..000000000 --- a/docs/man/nng_respondent.adoc +++ /dev/null @@ -1,90 +0,0 @@ -= nng_respondent(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_respondent - respondent protocol - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_respondent0_open(nng_socket *s); ----------- - -== DESCRIPTION - -The _nng_respondent_ protocol is one half of a survey pattern. -In this pattern, a surveyor sends a survey, which is broadcast to all -peer respondents. The respondents then have a chance to reply (but after -not obliged to). The survey itself is a timed event, so that responses -received after the survey has finished are discarded. - -TIP: This protocol is useful in solving voting problems, such as leader -election in cluster configurations, as well as certain kinds of service -discovery problems. - -The _nng_respondent_ protocol is the respondent side, and the -<> protocol is the surveyor side. - -=== Socket Operations - -The `nng_respondent0_open()` call creates a respondent socket. This socket -may be used to receive messages, and then to send replies. Generally -a reply can only be sent after receiving a survey, and generally the -reply will be sent to surveyor from whom the last survey was received. - -Respondents may discard a survey by simply not replying to it. - -Raw mode sockets (set with `NNG_OPT_RAW`) ignore all these restrictions. - -=== Protocol Versions - -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined. An earlier and -incompatible version of the protocol was used in older pre-releases of -http://nanomsg.org[nanomsg], but was not released in any production -version.) - -=== Protocol Options - -The following protocol-specific options are available. - -`NNG_OPT_MAXTTL`:: - - Maximum time-to-live. This option is an integer value - between 0 and 255, - inclusive, and is the maximum number of "hops" that a message may - pass through until it is discarded. The default value is 8. A value - of 0 may be used to disable the loop protection, allowing an infinite - number of hops. - -=== Protocol Headers - -The _nng_respondent_ protocol uses a _backtrace_ in the header. This -form uses an array of 32-bit big-endian identifiers, where the first -element in the array -identifies the local peer identifier to which the message will next be sent. -This is a hop-by-hop header where each element in a path adds routing -information to the end when sending a survey, and when replying removes -elements to obtain the next hop information. The survey ID is at the -end of this header and is inserted into the header as its first element -by the originating surveyor. (Survey IDs are distinguished from hops by -having their high order bit set to one.) - -// TODO: Insert reference to RFC. - -== SEE ALSO - -<>, -<> diff --git a/docs/man/nng_respondent_open.3.adoc b/docs/man/nng_respondent_open.3.adoc new file mode 100644 index 000000000..a62fc9d8e --- /dev/null +++ b/docs/man/nng_respondent_open.3.adoc @@ -0,0 +1,47 @@ += nng_respondent_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_respondent_open - create respondent socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_respondent0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_respondent0_open()` function creates a +<> +version 0 <> and returns it at the location +pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_send.adoc b/docs/man/nng_send.3.adoc similarity index 59% rename from docs/man/nng_send.adoc rename to docs/man/nng_send.3.adoc index 19034f331..22e09a80b 100644 --- a/docs/man/nng_send.adoc +++ b/docs/man/nng_send.3.adoc @@ -24,18 +24,18 @@ int nng_send(nng_socket s, void *data, size_t size, int flags); == DESCRIPTION -The `nng_send()` sends a message containing the _data_ of length _size_ -using the socket _s_. +The `nng_send()` function sends a message containing the _data_ of +length _size_ using the <> _s_. NOTE: The semantics of what sending a message means vary from protocol to -protocol, so examination of the protocol documentation is encouraged. (For -example, with an <> socket the data is broadcast, so that +protocol, so examination of the protocol documentation is encouraged. +(For example, with an <> socket the data is broadcast, so that any peers who have a suitable subscription will be able to receive it using -<> or a similar function.) Furthermore, some protocols -may not support sending data (such as <>) or may -require other conditions. (For example, <> sockets -cannot normally send data, which are responses to requests, until they have -first received a request.) +<> or a similar function.) +Furthermore, some protocols may not support sending data (such as +<>) or may require other conditions. +(For example, <> sockets cannot normally send data, +which are responses to requests, until they have first received a request.) The _flags_ may contain either of (or neither of) the following values: @@ -48,25 +48,27 @@ The _flags_ may contain either of (or neither of) the following values: then the function will block if such a condition exists. `NNG_FLAG_ALLOC`:: - The _data_ was allocated using <>, or was obtained - from a call to <> with the `NNG_FLAG_ALLOC` flag. + The _data_ was allocated using <>, or was + obtained from a call to <> with + the `NNG_FLAG_ALLOC` flag. If this function returns success, then the _data_ is "owned" by the function, and it will assume responsibility for calling - <> when it is no longer needed. In the absence - of this flag, the _data_ is copied by the implementation before the - function returns to the caller. + <> when it is no longer needed. + In the absence of this flag, the _data_ is copied by the implementation + before the function returns to the caller. TIP: The `NNG_FLAG_ALLOC` flag can be used to reduce data copies, thereby increasing performance. NOTE: Regardless of the presence or absence of `NNG_FLAG_NONBLOCK`, there may -be queues between the sender and the receiver. Furthermore, there is no -guarantee that the message has actually been delivered. Finally, with some -protocols, the semantic is implictly `NNG_FLAG_NONBLOCK`, such as with -<> sockets, which are best-effort delivery only. - -WARNING: When using `NNG_FLAG_ALLOC`, it is important that the value of _size_ -match the actual allocated size of the data. Using an incorrect size results +be queues between the sender and the receiver. +Furthermore, there is no guarantee that the message has actually been delivered. +Finally, with some protocols, the semantic is implictly `NNG_FLAG_NONBLOCK`, +such as with <> sockets, which are best-effort delivery only. + +IMPORTANT: When using `NNG_FLAG_ALLOC`, it is important that the value of _size_ +match the actual allocated size of the data. +Using an incorrect size results in unspecified behavior, which may include heap corruption, program crashes, or transdimensional mutation of the program's author. @@ -86,9 +88,10 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_send_aio.3.adoc b/docs/man/nng_send_aio.3.adoc new file mode 100644 index 000000000..bb1100158 --- /dev/null +++ b/docs/man/nng_send_aio.3.adoc @@ -0,0 +1,88 @@ += nng_send_aio(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_send_aio - send message asynchronously + +== SYNOPSIS + +[source, c] +---- +#include + +void nng_send_aio(nng_socket s, nng_aio *aio); +---- + +== DESCRIPTION + +The `nng_send_aio()` sends a <> using the +<> _s_ asynchronously. + +The message to send must have previously been set on the _aio_ +using the <> function. +The function assumes "`ownership`" of the message. + +If the message was successfully queued for delivery to the socket, +then the _aio_ will be completed, and <> +will return zero. In this case the socket will dispose of the +message when it is finished with it. + +NOTE: The operation will be "`completed`", and the callback associated +with the _aio_ executed, as soon as the socket accepts the message +for sending. +This does _not_ indicate that the message was actually delivered, as it +may still be buffered in the sending socket, buffered in the receiving +socket, or in flight over physical media. + +If the operation fails for any reason (including cancellation or timeout), +then the _aio_ callback will be executed and <> +will return a non-zero error status. +In this case, the callback has a responsibity to retrieve the message from +the _aio_ with <> and dispose of +it appropriately. +(This may include retrying the send operation on the same or a different +socket, or deallocating the message with <>.) + +NOTE: The semantics of what sending a message means varies from protocol to +protocol, so examination of the protocol documentation is encouraged. +(For example, with a <> socket the data is broadcast, so that +any peers who have a suitable subscription will be able to receive it using +<> or a similar function.) +Furthermore, some protocols may not support sending (such as +<>) or may require other conditions. +(For example, <> sockets cannot normally send data, which +are responses to requests, until they have first received a request.) + +== RETURN VALUES + +None. (The operation completes asynchronously.) + +== ERRORS + +`NNG_ECANCELED`:: The operation was aborted. +`NNG_ECLOSED`:: The socket _s_ is not open. +`NNG_EMSGSIZE`:: The message is too large. +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol for socket _s_ does not support sending. +`NNG_ESTATE`:: The socket _s_ cannot send data in this state. +`NNG_ETIMEDOUT`:: The send timeout expired. + +== SEE ALSO + +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_sendmsg.adoc b/docs/man/nng_sendmsg.3.adoc similarity index 57% rename from docs/man/nng_sendmsg.adoc rename to docs/man/nng_sendmsg.3.adoc index 708c1f3b1..e6d653b34 100644 --- a/docs/man/nng_sendmsg.adoc +++ b/docs/man/nng_sendmsg.3.adoc @@ -16,11 +16,11 @@ nng_sendmsg - send message == SYNOPSIS [source, c] ------------ +---- #include int nng_sendmsg(nng_socket s, nng_msg *msg, int flags); ------------ +---- == DESCRIPTION @@ -28,42 +28,43 @@ The `nng_sendmsg()` sends message _msg_ using the socket _s_. If the function returns zero, indicating it has accepted the message for delivery, then the _msg_ is "`owned`" by the socket _s_, and the caller -must not make any further use of it. The socket will free the message -when it is finished. +must not make any further use of it. +The socket will free the message when it is finished. If the function returns non-zero, then it is the caller's responsibility to dispose of the _msg_, which may include freeing it, sending it to another socket, or simply trying again later. TIP: Using this function gives access to the message structure, and may -offer more functionality than the simpler <> function. +offer more functionality than the simpler <> function. NOTE: The semantics of what sending a message means vary from protocol to -protocol, so examination of the protocol documentation is encouraged. (For -example, with an <> socket the data is broadcast, so that +protocol, so examination of the protocol documentation is encouraged. +(For example, with a <> socket the data is broadcast, so that any peers who have a suitable subscription will be able to receive it using -<> or a similar function.) Furthermore, some protocols -may not support sending (such as <>) or may -require other conditions. (For example, <> sockets -cannot normally send data, which are responses to requests, until they have -first received a request.) +<> or a similar function.) +Furthermore, some protocols may not support sending (such as +<>) or may require other conditions. +(For example, <> sockets cannot normally send data, which +are responses to requests, until they have first received a request.) The _flags_ may contain the following value: `NNG_FLAG_NONBLOCK`:: The function returns immediately, regardless of whether - the socket is able to accept the data or not. If the socket is unable - to accept the data (such as if backpressure exists because the peers - are consuming messages too slowly, or no peer is present), then the - function will return with `NNG_EAGAIN`. If this flag is not specified, - then the function will block if such a condition exists. + the socket is able to accept the data or not. + If the socket is unable to accept the data (such as if backpressure exists + because the peers are consuming messages too slowly, or no peer is present), + then the function will return with `NNG_EAGAIN`. + If this flag is not specified, then the function will block if such a + condition exists. NOTE: Regardless of the presence or absence of `NNG_FLAG_NONBLOCK`, there may -be queues between the sender and the receiver. Furthermore, there is no -guarantee that the message has actually been delivered. Finally, with some -protocols, the semantic is implictly `NNG_FLAG_NONBLOCK`, such as with -<> sockets, which are best-effort delivery only. +be queues between the sender and the receiver. +Furthermore, there is no guarantee that the message has actually been delivered. +Finally, with some protocols, the semantic is implictly `NNG_FLAG_NONBLOCK`, +such as with <> sockets, which are best-effort delivery only. == RETURN VALUES @@ -81,8 +82,10 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_setopt.adoc b/docs/man/nng_setopt.3.adoc similarity index 84% rename from docs/man/nng_setopt.adoc rename to docs/man/nng_setopt.3.adoc index 482d8c2bb..952848521 100644 --- a/docs/man/nng_setopt.adoc +++ b/docs/man/nng_setopt.3.adoc @@ -16,7 +16,7 @@ nng_setopt - set socket option == SYNOPSIS [source, c] ------------ +---- #include int nng_setopt(nng_socket s, const char *opt, const void *val, size_t valsz); @@ -32,15 +32,15 @@ int nng_setopt_size(nng_socket s, const char *opt, size_t z); int nng_setopt_string(nng_socket s, const char *opt, const char *str); int nng_setopt_uint64(nng_socket s, const char *opt, uint64_t u64); ------------ +---- == DESCRIPTION - -The `((nng_setopt))()` functions are used to configure options for +(((options, socket))) +The `nng_setopt()` functions are used to configure options for the socket _s_. The actual options that may be configured in this way vary, and are specified by _opt_. -A number of them are documented in <>. +A number of them are documented in <>. Additionally some transport-specific and protocol-specific options are documented with the transports and protocols themselves. @@ -65,15 +65,16 @@ The _ival_ is passed to the option. For booleans pass either 0 (`false`) or 1 (`true`). `nng_setopt_ms()`:: -This function is used to configure time durations (such as timeouts). +This function is used to configure time durations (such as timeouts) using +type <>. The duration _dur_ is an integer number of milliseconds. -(The special value ((`NNG_DUR_INFINITE`)) means an infinite amount of time.) `nng_setopt_ptr()`:: This function is used to pass a pointer, _ptr_, to structured data. The data referenced by _ptr_ is generally managed by other functions. -For example, TLS configuration objects -(<>) can be passed this way. +For example, TLS configuration objects created with +(<>) +can be passed this way. Note that this form is somewhat special in that the object is generally not copied, but instead the *pointer* to the object is copied. @@ -107,10 +108,10 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -[.text-left] -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_sleep_aio.adoc b/docs/man/nng_sleep_aio.3.adoc similarity index 73% rename from docs/man/nng_sleep_aio.adoc rename to docs/man/nng_sleep_aio.3.adoc index 8181046df..f83a75491 100644 --- a/docs/man/nng_sleep_aio.adoc +++ b/docs/man/nng_sleep_aio.3.adoc @@ -16,11 +16,11 @@ nng_sleep_aio - sleep asynchronously == SYNOPSIS [source, c] ------------ +---- #include void nng_sleep_aio(nng_duration msec, nng_aio *aio); ------------ +---- == DESCRIPTION @@ -29,7 +29,8 @@ causing the callback for _aio_ to be executed after _msec_ milliseconds. If the sleep finishes completely, the result will always be zero. NOTE: If a timeout is set on _aio_ using -<>, and it is shorter than _msec_, +<>, and it is shorter +than _msec_, then the sleep will wake up early, with a result code of `NNG_ETIMEDOUT`. == RETURN VALUES @@ -42,7 +43,10 @@ None. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_sockaddr.adoc b/docs/man/nng_sockaddr.5.adoc similarity index 58% rename from docs/man/nng_sockaddr.adoc rename to docs/man/nng_sockaddr.5.adoc index 396844e60..3d7b4fc2b 100644 --- a/docs/man/nng_sockaddr.adoc +++ b/docs/man/nng_sockaddr.5.adoc @@ -16,48 +16,48 @@ nng_sockaddr - socket address == SYNOPSIS [source, c] ------------ +---- #include -union nng_sockaddr { - uint16_t s_family; - nng_sockaddr_ipc s_ipc; - nng_sockaddr_inproc s_inproc; - nng_sockaddr_in s_in; - nng_sockaddr_in6 s_in6; - nng_sockaddr_zt s_zt; -}; -typedef union nng_sockaddr nng_sockaddr; +typedef union nng_sockaddr { + uint16_t s_family; + nng_sockaddr_ipc s_ipc; + nng_sockaddr_inproc s_inproc; + nng_sockaddr_in s_in; + nng_sockaddr_in6 s_in6; + nng_sockaddr_zt s_zt; +} nng_sockaddr; enum sockaddr_family { - NNG_AF_UNSPEC = 0, - NNG_AF_INPROC = 1, - NNG_AF_IPC = 2, - NNG_AF_INET = 3, - NNG_AF_INET6 = 4, - NNG_AF_ZT = 5, + NNG_AF_UNSPEC = 0, + NNG_AF_INPROC = 1, + NNG_AF_IPC = 2, + NNG_AF_INET = 3, + NNG_AF_INET6 = 4, + NNG_AF_ZT = 5, }; ------------ +---- == DESCRIPTION -An ((`nng_sockaddr`))(((socket, address))) is a structure used for +(((socket, address)))(((address, socket))) +An `nng_sockaddr` is a structure used for representing the addresses used by underlying transports, such as TCP/IP addresses, IPC paths, and so forth. -*** +**** The name `sockaddr` is based on it's similarity with POSIX `struct sockaddr`, but in the _nng_ library, these addreses are more closely affiliated with -instances of <> -than of <>. +instances of <> +than of <>. The naming confusion is unfortunate. -*** +**** This structure is actually a union, with different members for different types of addreses. Every member structure has as its first element a `uint16_t` field -containing the "`address family`"(((address family))). +containing the "`((address family))`". This overlaps the `s_family` member of the union, and indicates which specific member should be used. @@ -66,10 +66,10 @@ The values of `s_family` are as follows: `NNG_AF_UNSPEC`:: Invalid address, no other valid fields. `NNG_AF_INPROC`:: - Address for intraprocess communication (<>). + Address for intraprocess communication (<>). The `s_inproc` member is valid. `NNG_AF_IPC`:: - Address for interprocess communication (<>). + Address for interprocess communication (<>). The `s_path` member is valid. `NNG_AF_INET`:: Address for TCP/IP (v4) communication. @@ -78,16 +78,16 @@ The values of `s_family` are as follows: Address for TCP/IP (v6) communication. The `s_in6` member is valid. `NNG_AF_ZT`:: - Address for ZeroTier transport (<>). + Address for ZeroTier transport (<>). The `s_zt` member is valid. Please see the manual pages for each individual type for more information. == SEE ALSO -[.text-left] -<>, -<>, -<>, -<>, -<>, -<> + +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_sockaddr_in.5.adoc b/docs/man/nng_sockaddr_in.5.adoc new file mode 100644 index 000000000..94fa18be5 --- /dev/null +++ b/docs/man/nng_sockaddr_in.5.adoc @@ -0,0 +1,70 @@ += nng_sockaddr_in(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sockaddr_in - IPv4 socket address + +== SYNOPSIS + +[source, c] +---- +#include + +enum sockaddr_family { + NNG_AF_INET = 3, +}; + +typedef struct { + uint16_t sa_family; + uint16_t sa_port; + uint32_t sa_addr; +} nng_sockaddr_in; +---- + +== DESCRIPTION + +(((socket, address, IPv4))) +An `nng_sockaddr_in` is the flavor of <> +used to represent TCP (and sometimes UDP) addresses, +including the Internet Protocol (IP) address and port number.(((port number, TCP))) + +This structure is used with IPv4 addresses. +A different structure, <>, is used +for IPv6 addresses. + +The following structure members are present: + +`sa_family`:: + This field will always have the value ((`NNG_AF_INET`)). + +`sa_port`:: + This field holds the TCP or UDP port number, in network byte-order. + A zero value here is used when no specific port number is indicated. + +`sa_addr`:: + This field holds the ((IP addresss))(((address, IPv4))) in + network-byte order. + +TIP: The `sa_port` and `sa_addr` fields are in network-byte order to +facilitate their use with system APIs such as `inet_ntop()`. +Most platforms use some form of BSD-derived network API, which uses +network-byte order in the various structurs (such as `sockaddr_in`). + +IMPORTANT: This field appears similar to BSD `sockaddr_in`, but it is +_not_ the same, and they may not be used interchangeabley. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_sockaddr_in6.5.adoc b/docs/man/nng_sockaddr_in6.5.adoc new file mode 100644 index 000000000..f4164dd13 --- /dev/null +++ b/docs/man/nng_sockaddr_in6.5.adoc @@ -0,0 +1,71 @@ += nng_sockaddr_in6(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sockaddr_in - IPv6 socket address + +== SYNOPSIS + +[source, c] +---- +#include + +enum sockaddr_family { + NNG_AF_INET6 = 4, +}; + +typedef struct { + uint16_t sa_family; + uint16_t sa_port; + uint8_t sa_addr[16]; +} nng_sockaddr_in6; + +---- + +== DESCRIPTION + +(((socket, address, IPv6))) +An `nng_sockaddr_in6` is the flavor of <> +used to represent TCP (and sometimes UDP) addresses, +including the Internet Protocol (IP) address and port number.(((port number, TCP))) + +This structure is used with IPv6 addresses. +A different structure, <>, is used +for IPv4 addresses. + +The following structure members are present: + +`sa_family`:: + This field will always have the value ((`NNG_AF_INET6`)). + +`sa_port`:: + This field holds the TCP or UDP port number, in network byte-order. + A zero value here is used when no specific port number is indicated. + +`sa_addr`:: + This field holds the ((IP addresss))(((address, IPv6))) in + network-byte order. + +TIP: The `sa_port` and `sa_addr` fields are in network-byte order to +facilitate their use with system APIs such as `inet_ntop()`. +Most platforms use some form of BSD-derived network API, which uses +network-byte order in the various structurs (such as `sockaddr_in6`). + +IMPORTANT: This field appears similar to BSD `sockaddr_in6`, but it is +_not_ the same, and they may not be used interchangeabley. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_sockaddr_inproc.5.adoc b/docs/man/nng_sockaddr_inproc.5.adoc new file mode 100644 index 000000000..b65c3abed --- /dev/null +++ b/docs/man/nng_sockaddr_inproc.5.adoc @@ -0,0 +1,58 @@ += nng_sockaddr_inproc(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sockaddr_inproc - inproc socket address + +== SYNOPSIS + +[source, c] +---- +#include + +enum sockaddr_family { + NNG_AF_INPROC = 1, +}; + +typedef struct { + uint16_t sa_family; + uint16_t sa_name[128]; +} nng_sockaddr_inproc; +---- + +== DESCRIPTION + +(((socket, address, inproc))) +An `nng_sockaddr_inproc` is the flavor of <> +used to represent addresses associated with intra-process communication +using the <> transport. + +The following structure members are present: + +`sa_family`:: + This field will always have the value ((`NNG_AF_INPROC`)). + +`sa_name`:: + This field holds an arbitrary C string, which is the "`name`" of + the address. + The string must be `NUL` terminated, but no other restrictions exist. + +TIP: In order to ensure maximum compatibility, applications should avoid +hard coding the sizeof the `sa_name` member explicitly, but use the +`sizeof` operator to determine its actual size at compile time. +Furthermore, the size is guaranteed to be at least 128. + +== SEE ALSO + +<>, +<> +<> diff --git a/docs/man/nng_sockaddr_ipc.5.adoc b/docs/man/nng_sockaddr_ipc.5.adoc new file mode 100644 index 000000000..3003d51ee --- /dev/null +++ b/docs/man/nng_sockaddr_ipc.5.adoc @@ -0,0 +1,70 @@ += nng_sockaddr_ipc(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sockaddr_ipc - IPC socket address + +== SYNOPSIS + +[source, c] +---- +#include + +enum sockaddr_family { + NNG_AF_IPC = 2, +}; + +typedef struct { + uint16_t sa_family; + uint16_t sa_path[128]; +} nng_sockaddr_ipc; +---- + +== DESCRIPTION + +(((socket, address, IPC))) +An `nng_sockaddr_ipc` is the flavor of <> +used to represent addresses associated with IPC communication +using the <> transport. + +The following structure members are present: + +`sa_family`:: + This field will always have the value ((`NNG_AF_IPC`)). + +`sa_path`:: + This field holds the C string corresponding to pathname where the + IPC socket is located. + For systems using UNIX domain sockets, this will be an absolute + pathname in the filesystem, where the UNIX domain socket is located. + For Windows systems, this is the pathname of the Named Pipe, without + the leading `\\.pipe\` portion, which will be automatically added. + +NOTE: At this time, there is no support for Linux "`abstract sockets`". + +TIP: In order to ensure maximum compatibility, applications should avoid +hard coding the sizeof the `sa_path` member explicitly, but use the +`sizeof` operator to determine its actual size at compile time. +Furthermore, the size is guaranteed to be at least 128, but paths of +this length may not be supported on all systems. + +NOTE: If compatibility with legacy _nanomsg_ applications is required, +then pathnames must not be longer than 122 bytes, including the final +`NUL` byte. +This is because legacy versions of _nanomsg_ cannot express URLs +longer than 128 bytes, including the `ipc://` prefix. + +== SEE ALSO + +<>, +<> +<> diff --git a/docs/man/nng_sockaddr_zt.5.adoc b/docs/man/nng_sockaddr_zt.5.adoc new file mode 100644 index 000000000..0ff362764 --- /dev/null +++ b/docs/man/nng_sockaddr_zt.5.adoc @@ -0,0 +1,81 @@ += nng_sockaddr_zt(5) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sockaddr_zt - ZeroTier socket address + +== SYNOPSIS + +[source, c] +---- +#include + +enum sockaddr_family { + NNG_AF_ZT = 5, +}; + +typedef struct { + uint16_t sa_family; + uint64_t sa_nwid; + uint64_t sa_nodeid; + uint32_t sa_port; +} nng_sockaddr_zt; +---- + +== DESCRIPTION + +(((socket, address, ZeroTier))) +An `nng_sockaddr_zt` is the flavor of <> +used to represent ZeroTier addresses, including the +(((port number, ZeroTier)))port number used by the +<> transport. + +IMPORTANT: The ZeroTier transport, and the details of this structure, +are still considered experimental, and subject to change. + +The following structure members are present: + +`sa_family`:: + This field will always have the value ((`NNG_AF_ZT`)). + +`sa_nwid`:: + (((network number, ZeroTier))) + This field holds the ZeroTiero network number (or ID). + This value is in native byte order. + +`sa_nodeid`:: + This field holds the ZeroTier node ID.(((node ID, ZeroTier))) + This value is in native byte order, and only the lower 40 bits + are significant. + (ZeroTier node numbers are 40 bits long.) + A zero value here is used for a wild-card to indicate that the + caller's own node number be used. + +`sa_port`:: + This field holds the "`port number`" used by the + <> transport to distinguish different + sockets. + This value in native byte order.(((port number, ZeroTier))) + A zero value here indicates that a port number should be chosen + randomly from the ephemeral ports. + Only the lower 24 bits of the port number are used. + +NOTE: ZeroTier port numbers are in *native* byte order, and are larger +than TCP/IP port numbers. +They are also not part of the ZeroTier protocol itself, but defined by +the Scalability Protocols binding for them. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_socket.adoc b/docs/man/nng_socket.5.adoc similarity index 67% rename from docs/man/nng_socket.adoc rename to docs/man/nng_socket.5.adoc index 31df4a8f4..0dcdfa99c 100644 --- a/docs/man/nng_socket.adoc +++ b/docs/man/nng_socket.5.adoc @@ -16,20 +16,20 @@ nng_socket - socket handle == SYNOPSIS [source, c] ------------ +---- #include typedef uint32_t nng_socket; ------------ +---- == DESCRIPTION -An ((`nng_socket`))(((socket))) is a handle to an underlying "`socket`" object. +An `nng_socket`(((socket))) is a handle to an underlying "`socket`" object. All communication between the application and remote Scalability Protocol peers is done through sockets. -A given socket can have multiple dialers (<>) -and/or (<>), and multiple -pipes (<>), and +A given socket can have multiple dialers (<>) +and/or (<>), and multiple +pipes (<>), and may be connected to multiple transports at the same time. However, a given socket will have exactly one "`protocol`" associated with it, and is responsible for any state machines or other protocol-specific logic. @@ -39,16 +39,17 @@ ordinary file descriptors, and can only be used with the functions that explicitly indicate that it safe and appropropate to do so. Each `nng_socket` is created by a protocol-specific constructor, such as -<>. +<>. When the socket is no longer needed, it can be closed with -<>. +<>. == SEE ALSO -[.text-left] -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_strerror.adoc b/docs/man/nng_strerror.3.adoc similarity index 88% rename from docs/man/nng_strerror.adoc rename to docs/man/nng_strerror.3.adoc index c81a460f0..28ff85a41 100644 --- a/docs/man/nng_strerror.adoc +++ b/docs/man/nng_strerror.3.adoc @@ -16,11 +16,11 @@ nng_strerror - return an error description == SYNOPSIS [source, c] ------------ +---- #include const char * nng_strerror(int err); ------------ +---- == DESCRIPTION @@ -31,7 +31,8 @@ NOTE: The returned error message is provided in US English, but in the future locale-specific strings may be presented instead. NOTE: The specific strings associated with specific error messages are -subject to change. Therefore applications must not depend on the message, +subject to change. +Therefore applications must not depend on the message, but may use them verbatim when supplying information to end-users, such as in diagnostic messages or log entries. @@ -42,5 +43,5 @@ by a `NUL` byte. == SEE ALSO -<>, -<> +<>, +<> diff --git a/docs/man/nng_sub.adoc b/docs/man/nng_sub.7.adoc similarity index 59% rename from docs/man/nng_sub.adoc rename to docs/man/nng_sub.7.adoc index 579e4cf02..f222327dd 100644 --- a/docs/man/nng_sub.adoc +++ b/docs/man/nng_sub.7.adoc @@ -16,47 +16,49 @@ nng_sub - subscriber protocol == SYNOPSIS [source,c] ----------- +---- +#include #include int nng_sub0_open(nng_socket *s); ----------- +---- == DESCRIPTION -The _nng_sub_ protocol is one half of a publisher/subscriber pattern. -In this pattern, a publisher sends data, which is broadcast to all -subscribers. The subscribing applications only see the data to which -they have subscribed. +(((protocol, _sub_))) +The ((_sub_ protocol)) is one half of a publisher/((subscriber)) pattern. +In this pattern, a publisher sends data, which is broadcast to all subscribers. +The subscribing applications only see the data to which they have subscribed. -The _nng_sub_ protocol is the subscriber side, and the -<> protocol is the publisher side. +The _sub_ protocol is the subscriber side, and the +<> protocol is the publisher side. NOTE: In this implementation, the publisher delivers all messages to all -subscribers. The subscribers maintain their own subscriptions, and filter -them locally. Thus, this pattern should not be used in an attempt to +subscribers. +The subscribers maintain their own subscriptions, and filter them locally. +Thus, this pattern should not be used in an attempt to reduce bandwidth consumption. The topics that subscribers subscribe to is just the first part of -the message body. Applications should construct their messages -accordingly. +the message body. +Applications should construct their messages accordingly. === Socket Operations -The `nng_sub0_open()` call creates a subscriber socket. This socket -may be used to receive messages, but is unable to send them. Attempts -to send messages will result in `NNG_ENOTSUP`. +The <> call creates a subscriber socket. +This socket may be used to receive messages, but is unable to send them. +Attempts to send messages will result in `NNG_ENOTSUP`. === Protocol Versions -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined.) +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined.) === Protocol Options The following protocol-specific options are available. -`NNG_OPT_SUB_SUBSCRIBE`:: +((`NNG_OPT_SUB_SUBSCRIBE`))(((subscribe))):: This option registers a topic that the subscriber is interested in. The option is write-only, and takes an array of bytes, of arbitrary size. @@ -67,7 +69,7 @@ The following protocol-specific options are available. + TIP: To receive all messages, an empty topic (zero length) can be used. -`NNG_OPT_SUB_UNSUBSCRIBE`:: +((`NNG_OPT_SUB_UNSUBSCRIBE`)):: This option, also read-only, removes a topic from the subscription list. Note that if the topic was not previously subscribed to with @@ -75,9 +77,10 @@ TIP: To receive all messages, an empty topic (zero length) can be used. === Protocol Headers -The _nng_sub_ protocol has no protocol-specific headers. +The _sub_ protocol has no protocol-specific headers. == SEE ALSO -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_sub_open.3.adoc b/docs/man/nng_sub_open.3.adoc new file mode 100644 index 000000000..bfc315bbe --- /dev/null +++ b/docs/man/nng_sub_open.3.adoc @@ -0,0 +1,45 @@ += nng_sub_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_sub_open - create sub socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_sub0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_sub0_open()` function creates a <> version 0 +<> and returns it at the location pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_surveyor.7.adoc b/docs/man/nng_surveyor.7.adoc new file mode 100644 index 000000000..2c53e3ab2 --- /dev/null +++ b/docs/man/nng_surveyor.7.adoc @@ -0,0 +1,131 @@ += nng_surveyor(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_surveyor - surveyor protocol + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_surveyor0_open(nng_socket *s); +---- + +== DESCRIPTION + +(((protocol, _surveyor_))) +The ((_surveyor_ protocol)) is one half of a ((survey pattern)). +In this pattern, a surveyor sends a survey, which is broadcast to all +peer respondents. +The respondents then have a chance to reply (but are not obliged to reply). +The survey itself is a timed event, so that responses +received after the survey has finished are discarded. + +TIP: This protocol is useful in solving voting problems, such as +((leader election)) in cluster configurations, as well as certain kinds of +((service discovery)) problems. + +The _surveyor_ protocol is the surveyor side, and the +<> protocol is the respondent side. + +=== Socket Operations + +The <> +call creates a surveyor socket. +This socket may be used to send messages (surveys), and then to receive replies. +A reply can only be received after sending a survey. +A surveyor can normally expect to receive at most one reply from each responder. +(Messages can be duplicated in some topologies, +so there is no guarantee of this.) + +Attempts to receive on a socket with no outstanding survey will result +in `NNG_ESTATE`. +If the survey times out while the surveyor is waiting +for replies, then the result will be `NNG_ETIMEDOUT`. + +Only one survey can be outstanding at a time; sending another survey will +cancel the prior one, and any responses from respondents from the prior +survey that arrive after this will be discarded. + +Raw mode sockets (set with <>) +ignore all these restrictions. + +=== Protocol Versions + +Only version 0 of this protocol is supported. +(At the time of writing, no other versions of this protocol have been defined. +An earlier and incompatible version of the protocol was used in older +pre-releases of +http://nanomsg.org[nanomsg], but was not released in any production +version.) + +=== Protocol Options + +The following protocol-specific options is available. + +((`NNG_OPT_SURVEYOR_SURVEYTIME`)):: + + This read/write option is an <> + representing a postive number of milliseconds that following surveys + will last. + When a new survey is started, a timer of this duration is also started. + Any responses arriving this time will be discarded. + Attempts to receive + after the timer expires with no other surveys started will result in + `NNG_ESTATE`. + Attempts to receive when this timer expires will result in `NNG_ETIMEDOUT`. + +=== Protocol Headers + +(((backtrace))) +This form uses a "stack" of 32-bit big-endian identifiers. +There *must* be at least one identifier, the __survey ID__, which will be the +last element in the array, and *must* have the most significant bit set. + +There may be additional __peer ID__s preceeding the survey ID. +These will be distinguishable from the survey ID by having their most +significant bit clear. + +When a survey message is received by a forwarding node (see +<>), the forwarding node prepends a +32-bit peer ID (which *must* have the most significant bit clear), +which is the forwarder's way of identifying the directly connected +peer from which it received the message. +(This peer ID, except for the +most significant bit, has meaning only to the forwarding node itself.) + +It may help to think of prepending a peer ID as "pushing" a peer ID onto the +front of the stack of headers for the message. +(It will use the peer ID +it popped from the front to determine the next intermediate destination +for the response.) + +When a response message is created, it is created using the same headers +that the survey contained. + +A forwarding node can "pop" the peer ID it originally pushed on the +message, stripping it from the front of the message as it does so. + +When the response finally arrives back at the initiating surveyor, it +should have only a single element in the message, which will be the +survey ID it originally used for the request. + +// TODO: Insert reference to RFC. + +== SEE ALSO + +<>, +<>, +<> diff --git a/docs/man/nng_surveyor.adoc b/docs/man/nng_surveyor.adoc deleted file mode 100644 index 15937b277..000000000 --- a/docs/man/nng_surveyor.adoc +++ /dev/null @@ -1,107 +0,0 @@ -= nng_surveyor(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_surveyor - surveyor protocol - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_surveyor0_open(nng_socket *s); ----------- - -== DESCRIPTION - -The _nng_surveyor_ protocol is one half of a survey pattern. -In this pattern, a surveyor sends a survey, which is broadcast to all -peer respondents. The respondents then have a chance to reply (but after -not obliged to). The survey itself is a timed event, so that responses -received after the survey has finished are discarded. - -TIP: This protocol is useful in solving voting problems, such as leader -election in cluster configurations, as well as certain kinds of service -discovery problems. - -The _nng_surveyor_ protocol is the surveyor side, and the -<> protocol is the respondent side. - -=== Socket Operations - -The `nng_surveyor0_open()` call creates a respondent socket. This socket -may be used to send messages (surveys), and then to receive replies. Generally -a reply can only be received after sending a survey. Generally a surveyor -can expect to receive at most one reply from each responder. (Messages -can be duplicated in some topologies, so there is no guarantee of this.) - -Attempts to receive on a socket with no outstanding survey will result -in `NNG_ESTATE`. If the survey times out while the surveyor is waiting -for replies, then the result will be `NNG_ETIMEDOUT`. - -Only one survey can be outstanding at a time; sending another survey will -cancel the prior one, and any responses from respondents from the prior -survey that arrive after this will be discarded. - -Raw mode sockets (set with `NNG_OPT_RAW`) ignore all these restrictions. - -=== Protocol Versions - -Only version 0 of this protocol is supported. (At the time of writing, -no other versions of this protocol have been defined. An earlier and -incompatible version of the protocol was used in older pre-releases of -http://nanomsg.org[nanomsg], but was not released in any production -version.) - -=== Protocol Options - -The following protocol-specific options are available. - -`NNG_OPT_SURVEYOR_SURVEYTIME`:: - - This read/write option is a duration (32-bit unsigned integer) representing - a relative number of milliseconds that following surveys will last. - When a new survey is started, a timer of this duration is also started. - Any responses arriving this time will be discarded. Attempts to receive - after the timer expires with no other surveys started will result in - `NNG_ESTATE`. Attempts to receive when this timer expires will result in - `NNG_ETIMEDOUT`. - -`NNG_OPT_MAXTTL`:: - - Maximum time-to-live. This option is an integer value - between 0 and 255, - inclusive, and is the maximum number of "hops" that a message may - pass through until it is discarded. The default value is 8. A value - of 0 may be used to disable the loop protection, allowing an infinite - number of hops. - -=== Protocol Headers - -The _nng_surveyor_ protocol uses a _backtrace_ in the header. This -form uses an array of 32-bit big-endian identifiers, where the first -element in the array -identifies the local peer identifier to which the message will next be sent. -This is a hop-by-hop header where each element in a path adds routing -information to the end when sending a survey, and when replying removes -elements to obtain the next hop information. The survey ID is at the -end of this header and is inserted into the header as its first element -by the originating surveyor. (Survey IDs are distinguished from hops by -having their high order bit set to one.) - -// TODO: Insert reference to RFC. - -== SEE ALSO - -<>, -<> diff --git a/docs/man/nng_surveyor_open.3.adoc b/docs/man/nng_surveyor_open.3.adoc new file mode 100644 index 000000000..17be9889d --- /dev/null +++ b/docs/man/nng_surveyor_open.3.adoc @@ -0,0 +1,46 @@ += nng_surveyor_open(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_surveyor_open - create surveyor socket + +== SYNOPSIS + +[source,c] +---- +#include +#include + +int nng_surveyor0_open(nng_socket *s); +---- + +== DESCRIPTION + +The `nng_surveyor0_open()` function creates a <> +version 0 <> and returns it at the location +pointed to by _s_. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol is not supported. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tcp.7.adoc b/docs/man/nng_tcp.7.adoc new file mode 100644 index 000000000..9828b6589 --- /dev/null +++ b/docs/man/nng_tcp.7.adoc @@ -0,0 +1,93 @@ += nng_tcp(7) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_tcp - TCP/IP transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_tcp_register(void); +---- + +== DESCRIPTION + +(((transport, _tcp_))) +The ((_tcp_ transport)) provides communication support between +_nng_ sockets across a ((TCP/IP)) network. +Both IPv4 and IPv6 are supported when the underlying platform also supports it. + +// We need to insert a reference to the nanomsg RFC. + +=== Registration + +The _nng_tcp_ transport is generally built-in to the _nng_ core, so +no extra steps to use it should be necessary. + +=== URI Format + +(((URI, `tcp://`))) +This transport uses URIs using the scheme `tcp://`, followed by +an IP address or hostname, followed by a colon and finally a +TCP port number.(((port number, TCP))) +For example, to contact port 80 on the localhost either of the following URIs +could be used: `tcp://127.0.0.1:80` or `tcp://localhost:80`. + +When specifying IPv6 addresses, the address must be enclosed in +square brackets (`[]`) to avoid confusion with the final colon +separating the port. + +For example, the same port 80 on the IPv6 loopback address (`::1`) would +be specified as `tcp://[::1]:80`. + +NOTE: When using symbolic names, the name is resolved when the +name is first used. _nng_ won't become aware of changes in the +name resolution until restart, +usually. +(This is a bug and will likely be fixed in the future.) + +The special value of 0 (`INADDR_ANY`)(((`INADDR_ANY`))) +can be used for a listener to indicate that it should listen on all +interfaces on the host. +A short-hand for this form is to either omit the address, or specify +the asterisk (`*`) character. +For example, the following three URIs are all equivalent, +and could be used to listen to port 9999 on the host: + + 1. `tcp://0.0.0.0:9999` + 2. `tcp://*:9999` + 3. `tcp://:9999` + +The entire URI must be less than `NNG_MAXADDRLEN` bytes long. + +=== Socket Address + +When using an <> structure, +the actual structure is either of type +<> (for IPv4) or +<> (for IPv6). + +=== Transport Options + +The _nng_tcp_ transport has no special options. + +NOTE: Options for TCP keepalive, linger, and nodelay are planned. + +== SEE ALSO + +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tcp.adoc b/docs/man/nng_tcp.adoc deleted file mode 100644 index ad615e112..000000000 --- a/docs/man/nng_tcp.adoc +++ /dev/null @@ -1,115 +0,0 @@ -= nng_tcp(7) -// -// Copyright 2018 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// This document is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -== NAME - -nng_tcp - TCP/IP transport for nng - -== SYNOPSIS - -[source,c] ----------- -#include - -int nng_tcp_register(void); ----------- - -== DESCRIPTION - -The _nng_tcp_ transport provides communication support between -_nng_ sockets across a TCP/IP network. Both IPv4 and IPv6 -are supported when the underlying platform also supports it. - -// We need to insert a reference to the nanomsg RFC. - -=== Registration - -The _tcp_ transport is generally built-in to the _nng_ core, so -no extra steps to use it should be necessary. - -=== URI Format - -This transport uses URIs using the scheme `tcp://`, followed by -an IP address or hostname, followed by a colon and finally a -TCP port number. For example, to contact port 80 on the localhost -either of the following URIs could be used: `tcp://127.0.0.1:80` or -`tcp://localhost:80`. - -When specifying IPv6 addresses, the address must be enclosed in -square brackets (`[]`) to avoid confusion with the final colon -separating the port. - -For example, the same port 80 on the IPv6 loopback address ('::1') would -be specified as `tcp://[::1]:80`. - -NOTE: When using symbolic names, the name is resolved when the -name is first used. _nng_ won't become aware of changes in the -name resolution until restart, -usually.footnote:[This is a bug and will likely be fixed in the future.] - -The special value of 0 (`INADDR_ANY`) can be used for a listener -to indicate that it should listen on all interfaces on the host. -A short-hand for this form is to either omit the address, or specify -the asterisk (`*`) character. For example, the following three -URIs are all equivalent, and could be used to listen to port 9999 -on the host: - - 1. `tcp://0.0.0.0:9999` - 2. `tcp://*:9999` - 3. `tcp://:9999` - -The entire URI must be less than `NNG_MAXADDRLEN` bytes long. - -=== Socket Address - -When using an `nng_sockaddr` structure, the actual structure is either -of type `nng_sockaddr_in` (for IPv4) or `nng_sockaddr_in6` (for IPv6). -These are `struct` types with the following definitions: - -[source,c] --------- -#define NNG_AF_INET 3 <1> -#define NNG_AF_INET6 4 -#define NNG_MAXADDRLEN 128 - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_INET - uint16_t sa_port; // TCP port number - uint32_t sa_addr; - // ... -} nng_sockaddr_in; - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_INET6 - uint16_t sa_port; // TCP port number - uint8_t sa_addr[16]; - // ... -} nng_sockaddr_in6; --------- -<1> The values of these macros may change, so applications -should avoid depending upon their values and instead use them symbolically. -<2> Other members may be present, but only those listed here -are suitable for application use. - -The `sa_family` member will have the value `NNG_AF_INET` or `NNG_AF_INET6`. -The `sa_port` and `sa_addr` are the TCP port number and address, both in -network byte order (most significant byte is first). - -=== Transport Options - -The _tcp_ transport has no special -options.footnote:[Options for TCP keepalive, linger, and nodelay are planned.] - -== SEE ALSO - -<> diff --git a/docs/man/nng_tcp_register.3.adoc b/docs/man/nng_tcp_register.3.adoc new file mode 100644 index 000000000..440055543 --- /dev/null +++ b/docs/man/nng_tcp_register.3.adoc @@ -0,0 +1,42 @@ += nng_tcp_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_tcp_register - register tcp transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_tcp_register(void); +---- + +== DESCRIPTION + +The `nng_tcp_register()` function registers the +((_tcp_ transport))(((transport, _tcp_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_tls.adoc b/docs/man/nng_tls.7.adoc similarity index 54% rename from docs/man/nng_tls.adoc rename to docs/man/nng_tls.7.adoc index ca832085d..da4adeb6e 100644 --- a/docs/man/nng_tls.adoc +++ b/docs/man/nng_tls.7.adoc @@ -11,24 +11,25 @@ == NAME -nng_tls - TLS transport for nng +nng_tls - TLS transport == SYNOPSIS [source,c] ----------- +---- #include int nng_tls_register(void); ----------- +---- == DESCRIPTION -The _nng_tls_ transport provides communication support between +(((TLS)))(((Transport Layer Security)))(((transport, _tls_))) +The ((_tls_ transport)) provides communication support between _nng_ sockets across a TCP/IP network using https://tools.ietf.org/html/rfc5246[TLS v1.2] on top of -https://tools.ietf.org/html/rfc793[TCP]. Both IPv4 and IPv6 -are supported when the underlying platform also supports it. +https://tools.ietf.org/html/rfc793[TCP]. +Both IPv4 and IPv6 are supported when the underlying platform also supports it. The protocol details are documented in http://nanomsg.org/rfcs/sp-tls-v1.html[TLS Mapping for Scalability Protocols]. @@ -36,21 +37,20 @@ http://nanomsg.org/rfcs/sp-tls-v1.html[TLS Mapping for Scalability Protocols]. === Registration Depending upon how the library was built, it may be necessary to -register the transport by calling `nng_tls_register`. This function -returns zero on success, or an nng error value if the transport -cannot be initialized for any reason. +register the transport by calling +<>. === Availability The _tls_ transport depends on the use of an external library. -As of this writing, https://tls.mbed.org/[mbed TLS] version 2.0 +As of this writing, https://tls.mbed.org/[mbedTLS] version 2.0 or later is required. TIP: Applications may need to add this library (or libraries) to their link line, particularly when using a statically built _nng_ library. -NOTE: The mbed TLS library uses different licensing terms than +NOTE: The mbedTLS library uses different licensing terms than _nng_ itself; as of this writing it is offered under either https://opensource.org/licenses/Apache-2.0[Apache License 2.0] or https://opensource.org/licenses/gpl-license[GNU GPL] terms. @@ -59,9 +59,11 @@ license terms of any libraries you make use of. === URI Format +(((URI, `tls+tcp://`))) This transport uses URIs using the scheme `tls+tcp://`, followed by an IP address or hostname, followed by a colon and finally a -TCP port number. For example, to contact port 4433 on the localhost +TCP port number. +For example, to contact port 4433 on the localhost either of the following URIs could be used: `tls+tcp://127.0.0.1:4433` or `tls+tcp://localhost:4433`. @@ -75,19 +77,20 @@ be specified as `tls+tcp://[::1]:4433`. NOTE: When using symbolic names, the name is resolved when the name is first used. _nng_ won't become aware of changes in the name resolution until restart, -usually.footnote:[This is a bug and will likely be fixed in the future.] +usually. +(This is a bug and will likely be fixed in the future.) TIP: Certificate validation generally works when using names -rather than IP addresses. This transport automatically -uses the name supplied in the URL when validating the -certificate supplied by the server. +rather than IP addresses. +This transport automatically uses the name supplied in the URL when validating +the certificate supplied by the server. The special value of 0 (`INADDR_ANY`) can be used for a listener to indicate that it should listen on all interfaces on the host. A short-hand for this form is to either omit the address, or specify -the asterisk (`*`) character. For example, the following three -URIs are all equivalent, and could be used to listen to port 9999 -on the host: +the asterisk (`*`) character. +For example, the following three URIs are all equivalent, +and could be used to listen to port 9999 on the host: 1. `tls+tcp://0.0.0.0:9999` 2. `tls+tcp://*:9999` @@ -97,84 +100,59 @@ The entire URI must be less than `NNG_MAXADDRLEN` bytes long. === Socket Address -When using an `nng_sockaddr` structure, the actual structure is either -of type `nng_sockaddr_in` (for IPv4) or `nng_sockaddr_in6` (for IPv6). -These are `struct` types with the following definitions: - -[source,c] --------- -#define NNG_AF_INET 3 <1> -#define NNG_AF_INET6 4 -#define NNG_MAXADDRLEN 128 - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_INET - uint16_t sa_port; // TCP port number - uint32_t sa_addr; - // ... -} nng_sockaddr_in; - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_INET6 - uint16_t sa_port; // TCP port number - uint8_t sa_addr[16]; - // ... -} nng_sockaddr_in6; --------- -<1> The values of these macros may change, so applications -should avoid depending upon their values and instead use them symbolically. -<2> Other members may be present, but only those listed here -are suitable for application use. - -The `sa_family` member will have the value `NNG_AF_INET` or `NNG_AF_INET6`. -The `sa_port` and `sa_addr` are the TCP port number and address, both in -network byte order (most significant byte is first). +When using an <> structure, +the actual structure is either of type +<> (for IPv4) or +<> (for IPv6). === Transport Options -The following transport options are available. Note that -setting these must be done before the transport is started. +The following transport options are available. +Note that setting these must be done before the transport is started. -`NNG_OPT_TLS_CONFIG`:: +((`NNG_OPT_TLS_CONFIG`)):: This option is used on an endpoint to access the underlying TLS -configuration object. The value is of type `nng_tls_config *`. +configuration object. +The value is of type `nng_tls_config *`. TIP: Use this option when advanced TLS configuration is required. -`NNG_OPT_TLS_CA_FILE`:: +((`NNG_OPT_TLS_CA_FILE`)):: This is a write-only option used to load certificates associated associated private key from a file. -See <> for more +See <> for more information. -`NNG_OPT_TLS_CERT_KEY_FILE`:: +((`NNG_OPT_TLS_CERT_KEY_FILE`)):: This is a write-only option used to load the local certificate and associated private key from a file. The private key used must be unencrypted. (Use the `NNG_OPT_TLS_CONFIG` option to access the underlying TLS configuration if more advanced configuration is needed.) -See <> for more +See <> for more information. -`NNG_OPT_TLS_AUTH_MODE`:: +((`NNG_OPT_TLS_AUTH_MODE`)):: This is a write-only option used to configure the authentication mode used. It can take an integer with value `NNG_TLS_AUTH_MODE_NONE`, -`NNG_TLS_AUTH_MODE_REQUIRED`, or `NNG_TLS_AUTH_MODE_OPTIONAL`. See -<> for more details. +`NNG_TLS_AUTH_MODE_REQUIRED`, or `NNG_TLS_AUTH_MODE_OPTIONAL`. +See <> for +more details. -`NNG_OPT_TLS_VERIFIED`:: +((`NNG_OPT_TLS_VERIFIED`)):: This is a read-only option which returns a boolean value (integer 0 or 1). It will true (1) if the remote peer has been properly verified using TLS -authentication, or false (0) otherwise. This option may return incorrect +authentication, or false (0) otherwise. +This option may return incorrect results if peer authentication is disabled with `NNG_TLS_AUTH_MODE_NONE`. == SEE ALSO -<>, -<> +<> +<>, +<>, +<>, diff --git a/docs/man/nng_tls_config_alloc.adoc b/docs/man/nng_tls_config_alloc.3tls.adoc similarity index 76% rename from docs/man/nng_tls_config_alloc.adoc rename to docs/man/nng_tls_config_alloc.3tls.adoc index 09ea6051c..38d068ee4 100644 --- a/docs/man/nng_tls_config_alloc.adoc +++ b/docs/man/nng_tls_config_alloc.3tls.adoc @@ -1,4 +1,4 @@ -= nng_tls_config_alloc(3) += nng_tls_config_alloc(3tls) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -43,11 +43,13 @@ A TLS object can be further modified by functions that set the security keys used, peeer certificates, protocol policies, and so forth. A single TLS configuration object can be used with multiple TLS streams -or services. The underlying system uses reference counting to ensure +or services. +The underlying system uses reference counting to ensure that object is not inadvertently freed while in use. Also note that a TLS configuration object becomes "read-only" after it -is first used with a service. After this points, attempts to apply +is first used with a service. +After this points, attempts to apply further changes to the configuration will result in `NNG_EBUSY`. @@ -62,10 +64,10 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_config_auth_mode.adoc b/docs/man/nng_tls_config_auth_mode.3tls.adoc similarity index 61% rename from docs/man/nng_tls_config_auth_mode.adoc rename to docs/man/nng_tls_config_auth_mode.3tls.adoc index af27cb5e5..4a7901304 100644 --- a/docs/man/nng_tls_config_auth_mode.adoc +++ b/docs/man/nng_tls_config_auth_mode.3tls.adoc @@ -1,4 +1,4 @@ -= nng_tls_config_auth_mode(3) += nng_tls_config_auth_mode(3tls) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -31,24 +31,26 @@ int nng_tls_config_auth_mode(nni_tls_config *cfg, nng_tls_auth_mode mode); == DESCRIPTION -The `nng_tls_config_auth_mode()` function configures the authentication mode +The `nng_tls_config_auth_mode()` function configures the ((authentication mode)) to be used for TLS sessions using this configuration object. The possible modes are: -`NNG_TLS_AUTH_MODE_NONE`:: -No authentication of the TLS peer is performed. This is the default for +((`NNG_TLS_AUTH_MODE_NONE`)):: +No authentication of the TLS peer is performed. +This is the default for TLS servers, which most typically do not authenticate their clients. -`NNG_TLS_AUTH_MODE_OPTIONAL`:: -If a certificate is presented by the peer, then it is validated. However, -if the peer does not present a valid certificate, then the sesssion is allowed -to proceed without authentication. +((`NNG_TLS_AUTH_MODE_OPTIONAL`)):: +If a certificate is presented by the peer, then it is validated. +However, if the peer does not present a valid certificate, +then the sesssion is allowed to proceed without authentication. -`NNG_TLS_AUTH_MODE_REQUIRED`:: +((`NNG_TLS_AUTH_MODE_REQUIRED`)):: A check is made to ensure that the peer has presented a valid certificate -used for the session. If the peer's certificate is invalid or missing, then -the session is refused. This is the default for clients. +used for the session. +If the peer's certificate is invalid or missing, then the session is refused. +This is the default for clients. == RETURN VALUES @@ -63,9 +65,9 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_config_ca_chain.adoc b/docs/man/nng_tls_config_ca_chain.3tls.adoc similarity index 72% rename from docs/man/nng_tls_config_ca_chain.adoc rename to docs/man/nng_tls_config_ca_chain.3tls.adoc index 44258998b..2c105662d 100644 --- a/docs/man/nng_tls_config_ca_chain.adoc +++ b/docs/man/nng_tls_config_ca_chain.3tls.adoc @@ -16,18 +16,18 @@ nng_tls_config_ca_chain - configure certificate authority certificate chain == SYNOPSIS [source, c] ------------ +---- #include #include int nng_tls_config_ca_cert(nni_tls_config *cfg, const char *chain, const char *crl); ------------ +---- == DESCRIPTION The `nng_tls_config_ca_chain()` function configures a certificate or -certificate chain to be used when validating peers using the configuration +((certificate chain)) to be used when validating peers using the configuration _cfg_. NOTE: Certificates *must* be configured when using the authentication mode @@ -37,12 +37,12 @@ TIP: This function may be called multiple times, to add additional chains to a configuration, without affecting those added previously. The certificates located in _chain_ must be a zero-terminated C string in -https://tools.ietf.org/html/rfc7468[PEM] format. Multiple certificates may -appear concatenated together, with the leaf certificate listed first. -together. +https://tools.ietf.org/html/rfc7468[PEM] format. +Multiple certificates may appear concatenated together, +with the leaf certificate listed first. The _crl_ may be `NULL`, or may also be a C string containing a PEM format -certificate revocation list for the associated authority. +((certificate revocation list)) for the associated authority. == RETURN VALUES @@ -56,8 +56,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_config_ca_file.adoc b/docs/man/nng_tls_config_ca_file.3tls.adoc similarity index 71% rename from docs/man/nng_tls_config_ca_file.adoc rename to docs/man/nng_tls_config_ca_file.3tls.adoc index 6aeb7e01f..15e14eb7e 100644 --- a/docs/man/nng_tls_config_ca_file.adoc +++ b/docs/man/nng_tls_config_ca_file.3tls.adoc @@ -1,4 +1,4 @@ -= nng_tls_config_ca_file(3) += nng_tls_config_ca_file(3tls) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,21 +16,23 @@ nng_tls_config_ca_file - load certificate authority from file == SYNOPSIS [source, c] ------------ +---- #include #include int nng_tls_config_ca_file(nni_tls_config *cfg, const char *path); ------------ +---- == DESCRIPTION -The `nng_tls_config_ca_file()` function configures the certificate authority +The `nng_tls_config_ca_file()` function configures the ((certificate authority)) certificate chain and optional revocation list by loading the certificates -(and revocation list if present) from a single named file. The file must -at least one X.509 certificate in https://tools.ietf.org/html/rfc7468[PEM] +(and revocation list if present) from a single named file. +The file must at least one X.509 certificate in +https://tools.ietf.org/html/rfc7468[PEM] format, and may contain multiple such certificates, as well as zero or -more PEM CRL objects. This information is used to validate certificates +more PEM CRL objects. +This information is used to validate certificates that are presented by peers, when using the configuration _cfg_. NOTE: Certificates *must* be configured when using the authentication mode @@ -53,8 +55,8 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_config_cert_key_file.adoc b/docs/man/nng_tls_config_cert_key_file.3tls.adoc similarity index 72% rename from docs/man/nng_tls_config_cert_key_file.adoc rename to docs/man/nng_tls_config_cert_key_file.3tls.adoc index c511c5b50..8375f8074 100644 --- a/docs/man/nng_tls_config_cert_key_file.adoc +++ b/docs/man/nng_tls_config_cert_key_file.3tls.adoc @@ -1,4 +1,4 @@ -= nng_tls_config_cert_key_file(3) += nng_tls_config_cert_key_file(3tls) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,32 +16,34 @@ nng_tls_config_cert_key_file - load own certificate and key from file == SYNOPSIS [source, c] ------------ +---- #include #include int nng_tls_config_cert_key_file(nni_tls_config *cfg, const char *path, const char *pass); ------------ +---- == DESCRIPTION The `nng_tls_config_cert_key_file()` function loads a certificate (or -certificate chain) and a private key from the file named by _path_. +certificate chain) and a ((private key)) from the file named by _path_. The file must contain both the https://tools.ietf.org/html/rfc7468[PEM] encoded certificate and associated private key, which will be used when -establishing TLS sessions using _cfg_. It may contain additional certificates -leading to a validation chain, with the leaf certificate first. +establishing TLS sessions using _cfg_. +It may contain additional certificates leading to a validation chain, +with the leaf certificate first. There is no need to include the self-signed root, as the peer will need to have that already in order to perform it's own validation. The private key may be encrypted with a password, in which can be supplied in -_pass_. The value `NULL` should be supplied for _pass_ if the key is not -encrypted. +_pass_. +The value `NULL` should be supplied for _pass_ if the key is not encrypted. On servers, it is possible to call this function multiple times for the -same configuration. This can be useful for specifying different parameters +same configuration. +This can be useful for specifying different parameters to be used for different cryptographic algorithms. == RETURN VALUES @@ -58,7 +60,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_config_free.adoc b/docs/man/nng_tls_config_free.3tls.adoc similarity index 88% rename from docs/man/nng_tls_config_free.adoc rename to docs/man/nng_tls_config_free.3tls.adoc index 9bd55a34c..bac0ae553 100644 --- a/docs/man/nng_tls_config_free.adoc +++ b/docs/man/nng_tls_config_free.3tls.adoc @@ -1,4 +1,4 @@ -= nng_tls_config_alloc(3) += nng_tls_config_free(3tls) // // Copyright 2018 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV @@ -16,12 +16,12 @@ nng_tls_config_free - deallocate a TLS configuration object == SYNOPSIS [source, c] ------------ +---- #include #include void nng_tls_config_free(nni_tls_config *cfg); ------------ +---- == DESCRIPTION @@ -39,5 +39,5 @@ None. == SEE ALSO -<>, -<> +<>, +<> diff --git a/docs/man/nng_tls_config_own_cert.adoc b/docs/man/nng_tls_config_own_cert.3tls.adoc similarity index 76% rename from docs/man/nng_tls_config_own_cert.adoc rename to docs/man/nng_tls_config_own_cert.3tls.adoc index 7d2a081e8..0d6418a7d 100644 --- a/docs/man/nng_tls_config_own_cert.adoc +++ b/docs/man/nng_tls_config_own_cert.3tls.adoc @@ -16,29 +16,31 @@ nng_tls_config_own_cert - configure own certificate and key == SYNOPSIS [source, c] ------------ +---- #include #include int nng_tls_config_own_cert(nni_tls_config *cfg, const char *cert, const char *key, const char *pass); ------------ +---- == DESCRIPTION The `nng_tls_config_own_cert()` function configures a certificate _cert_ identifying the local side of a TLS connection used with _cfg_, along with an -associated private or secret key _key_. The certificate may be +associated private or secret key _key_. +The certificate may be a chain, with the leaf signer first and the root at the end. The -self-signed certificate at the end can be omitted. (The client should already +self-signed certificate at the end can be omitted. +(The client should already have it, and will have to in order to validate this certificate anyway). -The _key_ may be encrypted with a password, in which can be supplied in -_pass_. The value `NULL` should be supplied for _pass_ if the key is not -encrypted. +The _key_ may be encrypted with a password, in which can be supplied in _pass_. +The value `NULL` should be supplied for _pass_ if the key is not encrypted. On servers, it is possible to call this function multiple times for the -same configuration. This can be useful for specifying different parameters +same configuration. +This can be useful for specifying different parameters to be used for different cryptographic algorithms. The certificate located in _cert_ and _key_ must be NUL (`\0`) terminated C @@ -57,7 +59,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_config_server_name.adoc b/docs/man/nng_tls_config_server_name.3tls.adoc similarity index 67% rename from docs/man/nng_tls_config_server_name.adoc rename to docs/man/nng_tls_config_server_name.3tls.adoc index 8512d8012..c8f4b100b 100644 --- a/docs/man/nng_tls_config_server_name.adoc +++ b/docs/man/nng_tls_config_server_name.3tls.adoc @@ -16,20 +16,22 @@ nng_tls_config_server_name - configure remote server name == SYNOPSIS [source, c] ------------ +---- #include #include int nng_tls_config_server_name(nni_tls_config *cfg, const char *name); ------------ +---- == DESCRIPTION The `nng_tls_config_server_name()` function configures the remote server name -to be used by a client when connection to a server. The supplied _name_ -is used when comparing the identity in the server's certificate. Furthermore, -when Server Name Indication (SNI) is used, the _name_ may be sent to the server -as a hint to tell it which of several possible certificates should be used. +to be used by a client when connection to a server. +The supplied _name_ is used when comparing the identity in the +server's certificate. +Furthermore, when ((Server Name Indication)) (SNI) is used, the _name_ may +be sent to the server as a hint to tell it which of several possible +certificates should be used. TIP: This function is only useful in configuring client behavior. @@ -44,7 +46,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_tls_register.3.adoc b/docs/man/nng_tls_register.3.adoc new file mode 100644 index 000000000..a98a32118 --- /dev/null +++ b/docs/man/nng_tls_register.3.adoc @@ -0,0 +1,42 @@ += nng_tls_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_tls_register - register tls transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_tls_register(void); +---- + +== DESCRIPTION + +The `nng_tls_register()` function registers the +((_tls_ transport))(((transport, _tls_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_url_clone.adoc b/docs/man/nng_url_clone.3.adoc similarity index 75% rename from docs/man/nng_url_clone.adoc rename to docs/man/nng_url_clone.3.adoc index 4c0051202..b6553f6c9 100644 --- a/docs/man/nng_url_clone.adoc +++ b/docs/man/nng_url_clone.3.adoc @@ -16,17 +16,17 @@ nng_url_clone - clone URL structure == SYNOPSIS [source, c] ------------ +---- #include int nng_url_clone(nng_url **dup, nng_url *orig); ------------ +---- == DESCRIPTION The `nng_url_clone()` makes a clone of the original URL structure _orig_, and -saves the result in the location pointed by _dup_. This clone includes -fully duplicating each of the member fields. +saves the result in the location pointed by _dup_. +This clone includes fully duplicating each of the member fields. == RETURN VALUES @@ -38,7 +38,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_url_free.adoc b/docs/man/nng_url_free.3.adoc similarity index 85% rename from docs/man/nng_url_free.adoc rename to docs/man/nng_url_free.3.adoc index 427f6f483..62e3396ed 100644 --- a/docs/man/nng_url_free.adoc +++ b/docs/man/nng_url_free.3.adoc @@ -25,7 +25,7 @@ void nng_url_free(nng_url *url); == DESCRIPTION The `nng_url_free()` function deallocates the _url_ entirely, including -any of it's members. +any of its members. == RETURN VALUES @@ -37,6 +37,6 @@ None. == SEE ALSO -<>, -<>, -<> +<>, +<>, +<> diff --git a/docs/man/nng_url_parse.adoc b/docs/man/nng_url_parse.3.adoc similarity index 96% rename from docs/man/nng_url_parse.adoc rename to docs/man/nng_url_parse.3.adoc index c42d5c1c7..b109eecb2 100644 --- a/docs/man/nng_url_parse.adoc +++ b/docs/man/nng_url_parse.3.adoc @@ -88,7 +88,7 @@ This function returns 0 on success, and non-zero otherwise. == SEE ALSO -<>, -<>, -<>, -<> +<>, +<>, +<>, +<> diff --git a/docs/man/nng_version.adoc b/docs/man/nng_version.3.adoc similarity index 90% rename from docs/man/nng_version.adoc rename to docs/man/nng_version.3.adoc index bc578682a..347f14583 100644 --- a/docs/man/nng_version.adoc +++ b/docs/man/nng_version.3.adoc @@ -16,15 +16,15 @@ nng_version - report library version == SYNOPSIS [source, c] ------------ +---- #include const char * nng_version(void); ------------ +---- == DESCRIPTION -The ((`nng_version()`)) function returns a human readable ((version number)) +The `nng_version()` function returns a human readable ((version number)) for the _nng_ library. This is intended for output in programs, and so forth. @@ -53,5 +53,5 @@ None. == SEE ALSO -<>, -<> +<>, +<> diff --git a/docs/man/nng_ws.adoc b/docs/man/nng_ws.7.adoc similarity index 56% rename from docs/man/nng_ws.adoc rename to docs/man/nng_ws.7.adoc index 2ea361daa..f3d59a633 100644 --- a/docs/man/nng_ws.adoc +++ b/docs/man/nng_ws.7.adoc @@ -11,24 +11,25 @@ == NAME -nng_ws - WebSocket transport for nng +nng_ws - WebSocket transport == SYNOPSIS [source,c] ----------- +---- #include int nng_ws_register(void); int nng_wss_register(void); ----------- +---- == DESCRIPTION -The _nng_ws_ transport provides communication support between +(((WebSocket)))(((transport, _ws_ and _wss_))) +The ((_ws_ transport)) provides communication support between _nng_ sockets across a TCP/IP network using -https://tools.ietf.org/html/rfc6455[WebSockets]. Both IPv4 and IPv6 -are supported when the underlying platform also supports it. +https://tools.ietf.org/html/rfc6455[WebSockets]. +Both IPv4 and IPv6 are supported when the underlying platform also supports it. The protocol details are documented in http://nanomsg.org/rfcs/sp-websocket-v1.html[WebSocket Mapping for Scalability Protocols]. @@ -36,28 +37,26 @@ http://nanomsg.org/rfcs/sp-websocket-v1.html[WebSocket Mapping for Scalability P === Registration Depending upon how the library was built, it may be necessary to -register the transport by calling `nng_ws_register`. This function -returns zero on success, or an nng error value if the transport -cannot be initialized for any reason. +register the transport by calling <>. -If TLS support is enabled in the library, secure WebSockets (over TLS v1.2) +If ((TLS)) support is enabled in the library, secure WebSockets (over TLS v1.2) can be used as well, but the secure transport may have to be registered using -the `nng_wss_register` function. (Note that this function will not be -present if TLS support was not enabled in the library.) +the <> function. === URI Format +(((URI, `ws://`))) This transport uses URIs using the scheme `ws://`, followed by an IP address or hostname, optionally followed by a colon and an -TCP port number, optionally followed by a path. (If no port number -is specified then port 80 is assumed. If no path is specified then -a path of `/` is assumed.) +TCP port number, optionally followed by a path. +(If no port number is specified then port 80 is assumed. +If no path is specified then a path of `/` is assumed.) For example, the URI `ws://localhost/app/pubsub` would use port 80 on localhost, with the path `/app/pubsub`. -Secure WebSockets (if enabled) use the scheme `wss://`, and the default -TCP port number of 443. Otherwise the format is the same as for regular -WebSockets. +Secure WebSockets (((WebSockets, Secure)))(((URI, `wss://`))) +(if enabled) use the scheme `wss://`, and the default TCP port number of 443. +Otherwise the format is the same as for regular WebSockets. When specifying IPv6 addresses, the address must be enclosed in square brackets (`[]`) to avoid confusion with the final colon @@ -69,10 +68,10 @@ would be specified as `ws://[::1]/app/pubsub`. NOTE: When using symbolic names, the name is resolved when the name is first used. _nng_ won't become aware of changes in the name resolution until restart, -usually.footnote:[This is a bug and will likely be fixed in the future.] +usually. (This is a bug and will likely be fixed in the future.) NOTE: The value specified as the host, if any, will also be used -in the `Host:` HTTP header during HTTP negotiation. +in the `Host:` ((HTTP header)) during HTTP negotiation. To listen to all ports on the system, the host name may be elided from the URL on the listener. This will wind up listening to all interfaces @@ -83,50 +82,22 @@ permitted, with IPv4 addresses mapped to IPv6 addresses.) === Socket Address -When using an `nng_sockaddr` structure, the actual structure is either -of type `nng_sockaddr_in` (for IPv4) or `nng_sockaddr_in6` (for IPv6). -These are `struct` types with the following definitions: - -[source,c] --------- -#define NNG_AF_INET 3 <1> -#define NNG_AF_INET6 4 -#define NNG_MAXADDRLEN 128 - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_INET - uint16_t sa_port; // TCP port number - uint32_t sa_addr; - // ... -} nng_sockaddr_in; - -typedef struct { - // ... <2> - uint16_t sa_family; // must be NNG_AF_INET6 - uint16_t sa_port; // TCP port number - uint8_t sa_addr[16]; - // ... -} nng_sockaddr_in6; --------- -<1> The values of these macros may change, so applications -should avoid depending upon their values and instead use them symbolically. -<2> Other members may be present, but only those listed here -are suitable for application use. - -The `sa_family` member will have the value `NNG_AF_INET` or `NNG_AF_INET6`. -The `sa_port` and `sa_addr` are the TCP port number and address, both in -network byte order (most significant byte is first). +When using an <> structure, +the actual structure is either of type +<> (for IPv4) or +<> (for IPv6). === Server Instances -This transport makes use of shared HTTP server instances, permitting multiple -sockets or listeners to be configured with the same hostname and port. When -creating a new listener, it is registered with an existing HTTP server instance -if one can be found. Note that the matching algorithm is somewhat simple, -using only a string based hostname or IP address and port to match. Therefore -it is recommended to use only IP addresses or the empty string as the hostname -in listener URLs. +This transport makes use of shared HTTP server (((HTTP, server))) +instances, permitting multiple +sockets or listeners to be configured with the same hostname and port. +When creating a new listener, it is registered with an existing HTTP server +instance if one can be found. +Note that the matching algorithm is somewhat simple, +using only a string based hostname or IP address and port to match. +Therefore it is recommended to use only IP addresses or the empty string as +the hostname in listener URLs. Likewise, when sharing a server instance, it may not be possible to alter TLS configuration if the server is already running, as there is only a single @@ -146,49 +117,52 @@ setting these must be done before the transport is started. NOTE: The TLS specific options (beginning with `NNG_OPT_TLS_`) are only available for `wss://` endpoints. -`NNG_OPT_WS_REQUEST_HEADERS`:: +((`NNG_OPT_WS_REQUEST_HEADERS`)):: This value is a string, consisting of multiple lines terminated by CRLF sequences, that can be used to add further headers to the -HTTP request sent when connecting. This option can be set on dialers, -and retrieved from pipes. +HTTP request sent when connecting. +This option can be set on dialers, and retrieved from pipes. -`NNG_OPT_WS_RESPONSE_HEADERS`:: +((`NNG_OPT_WS_RESPONSE_HEADERS`)):: This value is a string, consisting of multiple lines terminated -by CRLF sequences, that can be used to add furthe headers to the -HTTP response sent when connecting. This option can be set on listeners, -and retrieved from pipes. +by CRLF sequences, that can be used to add further headers to the +HTTP response sent when connecting. +This option can be set on listeners, and retrieved from pipes. -`NNG_OPT_TLS_CONFIG`:: +((`NNG_OPT_TLS_CONFIG`)):: This option is used on an endpoint to access the underlying TLS configuration object. The value is of type `nng_tls_config *`. TIP: Use this option when advanced TLS configuration is required. -`NNG_OPT_TLS_CA_FILE`:: +((`NNG_OPT_TLS_CA_FILE`)):: This is a write-only option used to load certificates associated associated private key from a file. -See <> for more +See <> for more information. -`NNG_OPT_TLS_CERT_KEY_FILE`:: +((`NNG_OPT_TLS_CERT_KEY_FILE`)):: This is a write-only option used to load the local certificate and associated private key from a file. The private key used must be -unencrypted. (Use the `NNG_OPT_TLS_CONFIG` option to access the underlying +unencrypted. +(Use the `NNG_OPT_TLS_CONFIG` option to access the underlying TLS configuration if more advanced configuration is needed.) -See <> for more +See <> for more information. -`NNG_OPT_TLS_AUTH_MODE`:: +((`NNG_OPT_TLS_AUTH_MODE`)):: This is a write-only option used to configure the authentication mode -used. It can take an integer with value `NNG_TLS_AUTH_MODE_NONE`, -`NNG_TLS_AUTH_MODE_REQUIRED`, or `NNG_TLS_AUTH_MODE_OPTIONAL`. See -<> for more details. +used. +It can take an integer with value `NNG_TLS_AUTH_MODE_NONE`, +`NNG_TLS_AUTH_MODE_REQUIRED`, or `NNG_TLS_AUTH_MODE_OPTIONAL`. +See <> for more +details. `NNG_OPT_TLS_VERIFIED`:: @@ -205,5 +179,8 @@ results if peer authentication is disabled with `NNG_TLS_AUTH_MODE_NONE`. == SEE ALSO -<>, -<> +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/nng_ws_register.3.adoc b/docs/man/nng_ws_register.3.adoc new file mode 100644 index 000000000..f6b0d0683 --- /dev/null +++ b/docs/man/nng_ws_register.3.adoc @@ -0,0 +1,42 @@ += nng_ws_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_ws_register - register websocket transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_ws_register(void); +---- + +== DESCRIPTION + +The `nng_ws_register()` function registers the +((_ws_ transport))(((transport, _ws_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_wss_register.3.adoc b/docs/man/nng_wss_register.3.adoc new file mode 100644 index 000000000..b1ee36895 --- /dev/null +++ b/docs/man/nng_wss_register.3.adoc @@ -0,0 +1,42 @@ += nng_wss_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_ws_register - register websocket secure transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_wss_register(void); +---- + +== DESCRIPTION + +The `nng_wss_register()` function registers the +((_wss_ transport))(((transport, _wss_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nng_zerotier.adoc b/docs/man/nng_zerotier.7.adoc similarity index 64% rename from docs/man/nng_zerotier.adoc rename to docs/man/nng_zerotier.7.adoc index b77b8b8ce..04a684091 100644 --- a/docs/man/nng_zerotier.adoc +++ b/docs/man/nng_zerotier.7.adoc @@ -11,21 +11,21 @@ == NAME -nng_zerotier - ZeroTier transport for nng +nng_zerotier - ZeroTier transport == SYNOPSIS [source,c] ----------- +---- #include int nng_zt_register(void); ----------- +---- == DESCRIPTION -(((ZeroTier))) -The _nng_zerotier_ transport provides communication support for +(((ZeroTier)))(((transport, _zt_))) +The ((_zt_ transport)) provides communication support for _nng_ applications over a http://www.zerotier.com[ZeroTier] network, using a Virtual Layer 2 packet facility. @@ -58,7 +58,7 @@ concepts and administration. === Registration Depending upon how the library was built, it may be necessary to -register the transport by calling `nng_zt_register`. This function +register the transport by calling `nng_zt_register()`. This function returns zero on success, or an nng error value if the transport cannot be initialized for any reason. @@ -67,8 +67,9 @@ cannot be initialized for any reason. (((URI, `zt://`))) This transport uses URIs using the scheme `zt://`, followed by a node number (ten hexadecimal digits) followed by a `.` delimited, and then -a network address (sixteen hexadecimal digits), followed by a colon (`.`) -and service or port number (decimal value, up to 24-bits). +a network address (sixteen hexadecimal digits), followed by a colon (`:`) +and service or port number(((port number, ZeroTier))) (decimal value, +up to 24-bits). For example, the URI `zt://fedcba9876.0123456789abdef:999` indicates that node fedcba9876 on network 0123456789abcdef is listening on port 999. @@ -76,59 +77,38 @@ The special value `*` can be used in lieu of a node number to represent the node's own node number. Listeners may use port 0 to indicate that a suitable port -number be selected automatically. Applications using this must determine the -selected port number using the `nng_listener_getopt` function. +number be selected automatically. +Applications using this must determine the selected port number using the +<> function. === Socket Address -(((address, socket, zerotier))) -(((`NNG_AF_ZT`))) -(((`nng_sockaddr_zt`))) -When using an `nng_sockaddr` structure, the actual structure is of type -`struct nng_sockaddr_zt`. This type has the following definition: - -[source,c] --------- -#define NNG_AF_ZT 5 - -struct nng_sockaddr_zt { - uint16_t sa_family; // must be NNG_AF_ZT - uint64_t sa_nwid; // 64-bit network ID - uint64_t sa_nodeid; // 40-bit node ID - uint32_t sa_port; // 24-bit application port -} --------- - -The `sa_family` member will have the value `NNG_AF_ZT` (5). The remaining -members are, unlike TCP socket address, in native byte order. Only the -lower 24-bits of the `sa_port` may be used. Likewise only the lower 40-bits -of the `sa_nodeid` may be used. - -NOTE: The fields of this structure are in *native* byte order, -unlike the other socket address structures associated with `NNG_AF_INET` or -`NNG_AF_INET6`. +When using an <> structure, +the actual structure is of type +<>. === Node Presence By default this transport creates an "ephemeral" node, and used the -same ephemeral node for any additional endpoints created. As this node -is ephemeral, the keys associated with it and all associated data are -located in memory and are discarded upon application termination. If -a persistent node is desired, please see the `NNG_OPT_ZT_HOME` option -below. +same ((ephemeral node)) for any additional endpoints created. +As this node is ephemeral, the keys associated with it and all associated data +are located in memory and are discarded upon application termination. +If a ((persistent node)) is desired, please see the `NNG_OPT_ZT_HOME` option. It is possible for a single application to join multiple networks using the same node, or using separate nodes. === Network Status (((status, zerotier network))) -A ZeroTier node can be in one of the following states, which -can be obtained with the `NNG_OPT_ZT_NETWORK_STATUS` option: +A ZeroTier node can be in one of the following states, which can be obtained +with the `NNG_OPT_ZT_NETWORK_STATUS` option: +[[NNG_ZT_STATUS_UP]] ((`NNG_ZT_STATUS_UP`)):: -The ZeroTier network is up. This is the only state where it is -possible to communicate with peers, and the only state where -the network name (`NNG_OPT_ZT_NETWORK_NAME`) is available. +The ZeroTier network is up. +This is the only state where it is possible to communicate with peers, +and the only state where the network name (`NNG_OPT_ZT_NETWORK_NAME`) +is available. ((`NNG_ZT_STATUS_CONFIG`)):: The ZeroTier node is still configuring, network services are not available. @@ -155,16 +135,17 @@ The network is most likely not available. The following transport options are available: ((`NNG_OPT_ZT_HOME`)):: - This is a string representing the "home directory", where the transport + This is a string representing the "`home directory``", where the transport can store (and reuse) persistent state, such as key materials, node - identity, and federation membership. This option must be set before the - ZeroTier transport is first used. If this value is empty, then an ephemeral - ZeroTier node is created, and no persistent state is used. The default - is to use an ephemeral node. + identity, and federation membership. + This option must be set before the ZeroTier transport is first used. + If this value is empty, then an ephemeral ZeroTier node is created, + nd no persistent state is used. + The default is to use an ephemeral node. + NOTE: If this option is set to different values on different sockets, -dialers, or listeners, then separate nodes will be created. It -is perfectly valid for an application to have multiple node identities +dialers, or listeners, then separate nodes will be created. +It is perfectly valid for an application to have multiple node identities in this fashion. ((`NNG_OPT_ZT_NWID`)):: @@ -172,44 +153,54 @@ in this fashion. provides a `uint64_t` in native byte order representing the 64-bit ZeroTier network number. +[[NNG_OPT_ZT_NODE]] ((`NNG_OPT_ZT_NODE`)):: This is a read-only option for listeners, dialers, and pipes, and provides a `uint64_t` in native byte order representing the ZeroTier 40-bit node address. +[[NNG_OPT_ZT_NETWORK_STATUS]] ((`NNG_OPT_ZT_NETWORK_STATUS`)):: (((status, zerotier network))) This is a read-only integer, representing the ZeroTier network status. See <> for an explanation of this option. +[[NNG_OPT_ZT_NETWORK_NAME]] ((`NNG_OPT_ZT_NETWORK_NAME`)):: (((name, zerotier network))) This is a read-only ASCIIZ string containing the name of the network as established by the ZeroTier network administrator. +[[NNG_OPT_ZT_CONN_TIME]] ((`NNG_OPT_ZT_CONN_TIME`)):: - The time to wait between sending connection attempts. This is an - `nng_duration` (msec), and is only used with dialers. The default is 500 msec. + The time to wait between sending connection attempts. + This is an <> (msec), + and is only used with dialers. + The default is 500 msec. +[[NNG_OPT_ZT_CONN_TRIES]] ((`NNG_OPT_ZT_CONN_TRIES`)):: The maximum number (`int`) of attempts to try to establish a connection - before reporting a timeout, and is only used with dialers. The default - is 240, which results in a 2 minute timeout if `NNG_OPT_ZT_CONN_TIME` is at - it's default of 500. If the value is set to 0, then the connection - attempts will keep retrying forever. + before reporting a timeout, and is only used with dialers. + The default is 240, which results in a 2 minute timeout if + `NNG_OPT_ZT_CONN_TIME` is at it's default of 500. + If the value is set to 0, then connection attempts will keep retrying forever. +[[NNG_OPT_ZT_PING_TIME]] ((`NNG_OPT_ZT_PING_TIME`)):: If no traffic has been received from the ZeroTier peer after this - period of time, then a "ping" message is sent to check if the peer - is still alive. This is an `nng_duration` (msec). + period of time, then a "`ping``" message is sent to check if the peer + is still alive. This is an <> (msec). +[[NNG_OPT_ZT_PING_TRIES]] ((`NNG_OPT_ZT_PING_TRIES`)):: - If this number (`int`) of consecutive "ping" requests are sent to the + If this number (`int`) of consecutive "`ping``" requests are sent to the peer with no response (and no other intervening traffic), then the peer is assumed to be dead and the connection is closed. Note that if any traffic is received from the peer, then the underlying counter is reset to zero. +[[NNG_OPT_ZT_MTU]] ((`NNG_OPT_ZT_MTU`)):: This is a read-only size (`size_t`) representing the ZeroTier virtual network MTU; this is the Virtual Layer 2 MTU. The headers used by @@ -217,18 +208,20 @@ in this fashion. sent over the network. (The transport uses 20-bytes of this, and each protocol may consume additional space, typically not more than 16-bytes.) -((`NNG_OPT_ZT_ORBIT`)):: +[[NNG_OPT_ZT_ORBIT]] +((`NNG_OPT_ZT_ORBIT`))(((orbit, ZeroTier)))(((federation,ZeroTier))): This is a write-only option that takes an array of two `uint64_t` values, - indicating the ID of a ZeroTier "moon", and the node ID of the root server + indicating the ID of a ZeroTier "`moon``", and the node ID of the root server for that moon. (The ID may be zero if the moon ID is the same as it's root server ID, which is conventional.) +[[NNG_OPT_ZT_DEORBIT]] ((`NNG_OPT_ZT_DEORBIT`)):: This write-only option takes a single `uint64_t` indicating the moon - ID to "deorbit". If the node is not already orbiting the moon, then + ID to "`deorbit``". If the node is not already orbiting the moon, then this has no effect. == SEE ALSO -[.text-left] -<> +<>, +<> diff --git a/docs/man/nng_zerotier_register.3.adoc b/docs/man/nng_zerotier_register.3.adoc new file mode 100644 index 000000000..4998fe323 --- /dev/null +++ b/docs/man/nng_zerotier_register.3.adoc @@ -0,0 +1,42 @@ += nng_zerotier_register(3) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_zerotier_register - register ZeroTier transport + +== SYNOPSIS + +[source,c] +---- +#include + +int nng_zerotier_register(void); +---- + +== DESCRIPTION + +The `nng_zerotier_register()` function registers the +((_zt_ transport))(((transport, _zt_))) for use. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The transport is not supported. + +== SEE ALSO + +<>, +<> diff --git a/docs/man/nngcat.adoc b/docs/man/nngcat.1.adoc similarity index 68% rename from docs/man/nngcat.adoc rename to docs/man/nngcat.1.adoc index 18b4c3598..4bbaf002b 100644 --- a/docs/man/nngcat.adoc +++ b/docs/man/nngcat.1.adoc @@ -33,7 +33,8 @@ receiving messages. The possible values for _OPTION_ are described below. TIP: The _nngcat_ utility accepts shortened versions of these options, as long -as the supplied option is unambiguous. For example `--comp` can be used in lieu +as the supplied option is unambiguous. +For example `--comp` can be used in lieu of `--compat`, but `--re` may not be used for anything because it could mean any of `--req`, `--rep`, or `--respondent`. @@ -63,61 +64,66 @@ each option must be presented as a separate argument to the program. *--compat*:: Compatible mode. (((compatible mode))) This cause _nngcat_ to behave more like the legacy - _nanocat_ application. In this mode connections are made asynchronously, - and the *--pair* option selects version 0 of the <> - protocol instead of version 1. + _nanocat_ application. + In this mode connections are made asynchronously, + and the *--pair* option selects version 0 of + the <> protocol instead of version 1. *--subscribe*=_TOPIC_:: Subscribe to _TOPIC_. This option can only be used with the - <> protocol. The _TOPIC_ is checked against the - first bytes + <> protocol. + The _TOPIC_ is checked against the first bytes of messages received, and messages are discarded if they do not match. - This may be specified multiple times to subscribe to multiple topics. If - not specified at all, then a default subscription to everything is assumed. + This may be specified multiple times to subscribe to multiple topics. + If not specified at all, then a default subscription to everything is assumed. === Protocol Selection Options NOTE: At least one protocol must be selected. *--bus, --bus0*:: - Select the <> version 0 protocol. This protocol can send - and receive messages to and from other BUS version 0 peers. + Select the <> version 0 protocol. + This protocol can send and receive messages to and from other _bus_ version 0 + peers. *--req, --req0*:: - Select the <> version 0 protocol. This protocol sends - messages to <> version 0 peers and receives replies - from them. + Select the <> version 0 protocol. + This protocol sends messages to <> version 0 + peers and receives replies from them. *--rep, --rep0*:: - Select the <> version 0 protocol. This protocol - receives messages from <> version 0 peers and can send - replies to them. + Select the <> version 0 protocol. + This protocol receives messages from <> version 0 peers + and can send replies to them. *--pub, --pub0*:: - Select the <> version 0 protocol. This protocol sends - messages to <> version peers. + Select the <> version 0 protocol. + This protocol sends messages to <> version peers. *--sub, --sub0*:: - Select the <> version 0 protocol. - This protocol receives messages from <> version 0 peers, - and filters them based on subscriptions set with *--subscribe*. + Select the <> version 0 protocol. + This protocol receives messages from <> version + 0 peers, and filters them based on subscriptions set with *--subscribe*. *--push, --push0*:: - Select the <> version 0 protocol. - This protocol sends messages to <> version 0 peers. + Select the <> version 0 protocol. + This protocol sends messages to <> version 0 peers. A given message is normally only delivered to a single peer. *--pull, --pull0*:: - Select the <> version 0 protocol. + Select the <> version 0 protocol. This protocol receives - messages from <> version 0 peers. + messages from <> version 0 peers. *--pair0*:: - Select the <> veresion 0 protocol. This protocol - can send and receive messages with one connected PAIR version 0 peer. + Select the <> veresion 0 protocol. + This protocol can send and receive messages with one connected _pair_ + version 0 peer. *--pair1*:: - Select the <> version 1 protocol. This protocol - can send and receive messages with one connected PAIR version 1 peer. It - is not supported in *--compat* mode. (Polyamorous mode is not supported + Select the <> version 1 protocol. + This protocol can send and receive messages with one connected _pair_ + version 1 peer. + It is not supported in *--compat* mode. + (Polyamorous mode is not supported in _nngcat_, although peers may be using polyamorous mode.) *--pair*:: @@ -125,13 +131,13 @@ NOTE: At least one protocol must be selected. which case it acts as an alias for *--pair0*. *--surveyor, --surveyor0*:: - Select the <> version 0 protocol. - This protocol sends a survey request to <> + Select the <> version 0 protocol. + This protocol sends a survey request to <> version 0 peers, and then receives replies from them. *--respondent, --respondent0*:: - Select the <> version 0 protocol. - This protocol receives survey requests from <> + Select the <> version 0 protocol. + This protocol receives survey requests from > version 0 peers, and can send a reply to them. === Peer Selection Options @@ -208,8 +214,7 @@ options can only be specified when using a protocol that receives messages. === Transmit Options -Protocols that support sending data can use these options to select -the data. +Protocols that support sending data can use these options to select the data. *-D, --data*=_DATA_:: Use _DATA_ for the body of outgoing messages. @@ -223,9 +228,9 @@ the data. outgoing message at repeating intervals of _SEC_ seconds. *-d, --delay*=_SEC_:: - Wait _SEC_ seconds before sending the first outgoing message. This is - useful to let connections establish before sending data, thereby avoiding - message loss. + Wait _SEC_ seconds before sending the first outgoing message. + This is useful to let connections establish before sending data, thereby + avoiding message loss. *--send-timeout*=_SEC_:: Give up trying to send a message after _SEC_ seconds. @@ -242,12 +247,14 @@ when using addresses that are not secured with TLS. Load own certificate from _FILE_. *--key*=_FILE_:: - Load own key from _FILE_. Should be used in conjuction with *--cert*. If - not specified, and *--cert* is specified, then a single file containing both + Load own key from _FILE_. + Should be used in conjuction with *--cert*. + If not specified, and *--cert* is specified, then a single file containing both the private key and the associated certificate is assumed. *--cacert*=_FILE_:: - Load CA certificates from _FILE_. These CAs ("Certificate Authorities") are + Load CA certificates from _FILE_. + These CAs ("Certificate Authorities") are used as trust roots when validating certificates presented by peers. === ZeroTier Options @@ -256,8 +263,9 @@ These options are only present if ZeroTier is configured; they are ignored otherwise. *--zt-home*=_DIRECTORY_:: - Directory for persistent ZeroTier node (key material, etc.) This directory - must already exist. Only one program may use a ZeroTier node at a time; + Directory for persistent ZeroTier node (key material, etc.) + This directory must already exist. + Only one program may use a ZeroTier node at a time; file locking is used to prevent this. == EXAMPLES @@ -283,17 +291,16 @@ $ nngcat --sub --dial=${addr} --quoted & == SEE ALSO -[.text-left] -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<>, -<> +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<>, +<> diff --git a/docs/man/preview.sh b/docs/man/preview.sh index 7628fc7f9..d38b2a780 100755 --- a/docs/man/preview.sh +++ b/docs/man/preview.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/ksh # # Copyright 2018 Staysail Systems, Inc. # Copyright 2018 Capitar IT Group BV @@ -120,9 +120,23 @@ else fi for input in "$@"; do + subdir=$(dirname $input) + parent=$(basename $subdir) + case "${parent}" in + man[0-9a-zA-Z_]*) + echo doing subdir ${parent} + subdir=${parent}/ + outdir="${tempdir}/${subdir}" + [[ -d ${outdir} ]] || mkdir -p ${outdir} + ;; + *) + subdir="" + outdir="${tempdir}" + ;; + esac base=$(basename $input) base=${base%.adoc} - output=${tempdir}/${base}${suffix} + output=${outdir}/${base}${suffix} generate_${style} $input $output $OPEN $output done