= libnng(3) // // Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2019 Devolutions // Copyright 2020 Dirac Research // // 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 === Connection Management The following functions are used with either listeners, or dialers. Listeners accept incoming connection requests, and dialers make them. |=== |xref:nng_dial.3.adoc[nng_dial()]|create and start dialer |xref:nng_dialer_close.3.adoc[nng_dialer_close()]|close dialer |xref:nng_dialer_create.3.adoc[nng_dialer_create()]|create dialer |xref:nng_dialer_get.3.adoc[nng_dialer_get()]|get dialer option |xref:nng_dialer_id.3.adoc[nng_dialer_id()]|get numeric dialer identifier |xref:nng_dialer_set.3.adoc[nng_dialer_set()]|set dialer option |xref:nng_dialer_start.3.adoc[nng_dialer_start()]|start dialer |xref:nng_listen.3.adoc[nng_listen()]|create and start listener |xref:nng_listener_close.3.adoc[nng_listener_close()]|close listener |xref:nng_listener_create.3.adoc[nng_listener_create()]|create listener |xref:nng_listener_get.3.adoc[nng_listener_get()]|get listener option |xref:nng_listener_id.3.adoc[nng_listener_id()]|get numeric listener identifier |xref:nng_listener_set.3.adoc[nng_listener_set()]|set listener option |xref:nng_listener_start.3.adoc[nng_listener_start()]|start listener |xref:nng_pipe_close.3.adoc[nng_pipe_close()]|close pipe |xref:nng_pipe_dialer.3.adoc[nng_pipe_dialer()]|return dialer that created pipe |xref:nng_pipe_get.3.adoc[nng_pipe_get()]|get pipe option |xref:nng_pipe_id.3.adoc[nng_pipe_id()]|get numeric pipe identifier |xref:nng_pipe_listener.3.adoc[nng_pipe_listener()]|return listener that created pipe |xref:nng_pipe_notify.3.adoc[nng_pipe_notify()]|register pipe notification callback |xref:nng_pipe_socket.3.adoc[nng_pipe_socket()]|return owning socket for pipe |=== === Asynchronous Operations Most applications will interact with _NNG_ synchronously; that is that functions such as xref:nng_send.3.adoc[`nng_send()`] 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 is executed. A context structure, an xref:nng_aio.5.adoc[`nng_aio`], 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: |=== |xref:nng_aio_reset.3.adoc[nng_aio_reset()]|reset asynchronous I/O operation |xref:nng_aio_start.3.adoc[nng_aio_start()]|start asynchronous I/O operation |xref:nng_aio_finish.3.adoc[nng_aio_finish()]|finish asynchronous I/O operation |xref:nng_aio_get_input.3.adoc[nng_aio_get_input()]|return input parameter |xref:nng_aio_set_output.3.adoc[nng_aio_set_output()]|set output result |=== === Devices, Relays The following function family is used to create forwarders or relayers that route messages from one socket to another. |=== |xref:nng_device.3.adoc[nng_device()]|message forwarding device |=== === 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. |=== |xref:nng_http_conn_close.3http.adoc[nng_http_conn_close()]|close HTTP connection |xref:nng_http_conn_read.3http.adoc[nng_http_conn_read()]|read from HTTP connection |xref:nng_http_conn_read_all.3http.adoc[nng_http_conn_read_all()]|read all from HTTP connection |xref:nng_http_conn_read_req.3http.adoc[nng_http_conn_read_req()]|read HTTP request |xref:nng_http_conn_read_res.3http.adoc[nng_http_conn_read_res()]|read HTTP response |xref:nng_http_conn_write.3http.adoc[nng_http_conn_write()]|write to HTTP connection |xref:nng_http_conn_write_all.3http.adoc[nng_http_conn_write_all()]|write all to HTTP connection |xref:nng_http_conn_write_req.3http.adoc[nng_http_conn_write_req()]|write HTTP request |xref:nng_http_conn_write_res.3http.adoc[nng_http_conn_write_res()]|write HTTP response |xref:nng_http_req_add_header.3http.adoc[nng_http_req_add_header()]|add HTTP request header |xref:nng_http_req_alloc.3http.adoc[nng_http_req_alloc()]|allocate HTTP request structure |xref:nng_http_req_copy_data.3http.adoc[nng_http_req_copy_data()]|copy HTTP request body |xref:nng_http_req_del_header.3http.adoc[nng_http_req_del_header()]|delete HTTP request header |xref:nng_http_req_free.3http.adoc[nng_http_req_free()]|free HTTP request structure |xref:nng_http_req_get_data.3http.adoc[nng_http_req_get_data()]|get HTTP request body |xref:nng_http_req_get_header.3http.adoc[nng_http_req_get_header()]|return HTTP request header |xref:nng_http_req_get_method.3http.adoc[nng_http_req_get_method()]|return HTTP request method |xref:nng_http_req_get_uri.3http.adoc[nng_http_req_get_uri()]|return HTTP request URI |xref:nng_http_req_get_version.3http.adoc[nng_http_req_get_version()]|return HTTP request protocol version |xref:nng_http_req_reset.3http.adoc[nng_http_req_reset()]|reset HTTP request structure |xref:nng_http_req_set_data.3http.adoc[nng_http_req_set_data()]|set HTTP request body |xref:nng_http_req_set_header.3http.adoc[nng_http_req_set_header()]|set HTTP request header |xref:nng_http_req_set_method.3http.adoc[nng_http_req_set_method()]|set HTTP request method |xref:nng_http_req_set_uri.3http.adoc[nng_http_req_set_uri()]|set HTTP request URI |xref:nng_http_req_set_version.3http.adoc[nng_http_req_set_version()]|set HTTP request protocol version |xref:nng_http_res_add_header.3http.adoc[nng_http_res_add_header()]|add HTTP response header |xref:nng_http_res_alloc.3http.adoc[nng_http_res_alloc()]|allocate HTTP response structure |xref:nng_http_res_alloc_error.3http.adoc[nng_http_res_alloc_error()]|allocate HTTP error response |xref:nng_http_res_copy_data.3http.adoc[nng_http_res_copy_data()]|copy HTTP response body |xref:nng_http_res_del_header.3http.adoc[nng_http_res_del_header()]|delete HTTP response header |xref:nng_http_res_free.3http.adoc[nng_http_res_free()]|free HTTP response structure |xref:nng_http_res_get_data.3http.adoc[nng_http_res_get_data()]|get HTTP response body |xref:nng_http_res_get_header.3http.adoc[nng_http_res_get_header()]|return HTTP response header |xref:nng_http_res_get_reason.3http.adoc[nng_http_res_get_reason()]|return HTTP response reason |xref:nng_http_res_get_status.3http.adoc[nng_http_res_get_status()]|return HTTP response status |xref:nng_http_res_get_version.3http.adoc[nng_http_res_get_version()]|return HTTP response protocol version |xref:nng_http_res_reset.3http.adoc[nng_http_res_reset()]|reset HTTP response structure |xref:nng_http_res_set_data.3http.adoc[nng_http_res_set_data()]|set HTTP response body |xref:nng_http_res_set_header.3http.adoc[nng_http_res_set_header()]|set HTTP response header |xref:nng_http_res_set_reason.3http.adoc[nng_http_res_set_reason()]|set HTTP response reason |xref:nng_http_res_set_status.3http.adoc[nng_http_res_set_status()]|set HTTP response status |xref:nng_http_res_set_version.3http.adoc[nng_http_res_set_version()]|set HTTP response protocol version |=== ==== HTTP Client Functions These functions are intended for use with HTTP client applications. |=== |xref:nng_http_client_alloc.3http.adoc[nng_http_client_alloc()]|allocate HTTP client |xref:nng_http_client_connect.3http.adoc[nng_http_client_connect()]|establish HTTP client connection |xref:nng_http_client_free.3http.adoc[nng_http_client_free()]|free HTTP client |xref:nng_http_client_get_tls.3http.adoc[nng_http_client_get_tls()]|get HTTP client TLS configuration |xref:nng_http_client_set_tls.3http.adoc[nng_http_client_set_tls()]|set HTTP client TLS configuration |xref:nng_http_client_transact.3http.adoc[nng_http_client_transact()]|perform one HTTP transaction |xref:nng_http_conn_transact.3http.adoc[nng_http_conn_transact()]|perform one HTTP transaction on connection |=== ==== HTTP Server Functions These functions are intended for use with HTTP server applications. |=== |xref:nng_http_handler_alloc.3http.adoc[nng_http_handler_alloc()]|allocate HTTP server handler |xref:nng_http_handler_collect_body.3http.adoc[nng_http_handler_collect_body()]|set HTTP handler to collect request body |xref:nng_http_handler_free.3http.adoc[nng_http_handler_free()]|free HTTP server handler |xref:nng_http_handler_get_data.3http.adoc[nng_http_handler_get_data()]|return extra data for HTTP handler |xref:nng_http_handler_set_data.3http.adoc[nng_http_handler_set_data()]|set extra data for HTTP handler |xref:nng_http_handler_set_host.3http.adoc[nng_http_handler_set_host()]|set host for HTTP handler |xref:nng_http_handler_set_method.3http.adoc[nng_http_handler_set_method()]|set HTTP handler method |xref:nng_http_handler_set_tree.3http.adoc[nng_http_handler_set_tree()]|set HTTP handler to match trees |xref:nng_http_hijack.3http.adoc[nng_http_hijack()]|hijack HTTP server connection |xref:nng_http_server_add_handler.3http.adoc[nng_http_server_add_handler()]|add HTTP server handler |xref:nng_http_server_del_handler.3http.adoc[nng_http_server_del_handler()]|delete HTTP server handler |xref:nng_http_server_get_addr.3http.adoc[nng_http_server_get_addr()]|get HTTP server address |xref:nng_http_server_get_tls.3http.adoc[nng_http_server_get_tls()]|get HTTP server TLS configuration |xref:nng_http_server_hold.3http.adoc[nng_http_server_hold()]|get and hold HTTP server instance |xref:nng_http_server_release.3http.adoc[nng_http_server_release()]|release HTTP server instance |xref:nng_http_server_set_error_file.3http.adoc[nng_http_server_set_error_file()]|set custom HTTP error file |xref:nng_http_server_set_error_page.3http.adoc[nng_http_server_set_error_page()]|set custom HTTP error page |xref:nng_http_server_set_tls.3http.adoc[nng_http_server_set_tls()]|set HTTP server TLS configuration |xref:nng_http_server_res_error.3http.adoc[nng_http_server_res_error()]|use HTTP server error page |xref:nng_http_server_start.3http.adoc[nng_http_server_start()]|start HTTP server |xref:nng_http_server_stop.3http.adoc[nng_http_server_stop()]|stop HTTP server |=== === TLS Configuration Objects The following functions are used to manipulate transport layer security (TLS) configuration objects. Most of these functions will not be used even by TLS applications. NOTE: These functions will only be present if the library has been built with TLS support. |=== |xref:nng_tls_config_alloc.3tls.adoc[nng_tls_config_alloc()]|allocate TLS configuration |xref:nng_tls_config_auth_mode.3tls.adoc[nng_tls_config_auth_mode()]|set authentication mode |xref:nng_tls_config_ca_chain.3tls.adoc[nng_tls_config_ca_chain()]|set certificate authority chain |xref:nng_tls_config_ca_file.3tls.adoc[nng_tls_config_ca_file()]|load certificate authority from file |xref:nng_tls_config_cert_key_file.3tls.adoc[nng_tls_config_cert_key_file()]|load own certificate and key from file |xref:nng_tls_config_psk.3tls.adoc[nng_tls_config_psk()]|set pre-shared key and identity |xref:nng_tls_config_own_cert.3tls.adoc[nng_tls_config_own_cert()]|set own certificate and key |xref:nng_tls_config_free.3tls.adoc[nng_tls_config_free()]|free TLS configuration |xref:nng_tls_config_server_name.3tls.adoc[nng_tls_config_server_name()]|set remote server name |=== == SEE ALSO [.text-left] xref:nng.7.adoc[nng(7)]