diff options
| -rw-r--r-- | docs/man/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | docs/man/libnng.3.adoc | 1 | ||||
| -rw-r--r-- | docs/man/nng_stream.5.adoc | 7 | ||||
| -rw-r--r-- | docs/man/nng_stream_get.3str.adoc | 3 | ||||
| -rw-r--r-- | docs/man/nng_stream_set.3str.adoc | 112 | ||||
| -rw-r--r-- | docs/ref/migrate/nng1.md | 13 | ||||
| -rw-r--r-- | include/nng/nng.h | 8 | ||||
| -rw-r--r-- | src/core/stream.c | 56 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpconn.c | 54 | ||||
| -rw-r--r-- | src/platform/windows/win_tcpconn.c | 39 | ||||
| -rw-r--r-- | src/supplemental/http/http_api.h | 4 | ||||
| -rw-r--r-- | src/supplemental/http/http_conn.c | 15 | ||||
| -rw-r--r-- | src/supplemental/tls/tls_common.c | 16 | ||||
| -rw-r--r-- | src/supplemental/websocket/websocket.c | 29 | ||||
| -rw-r--r-- | src/supplemental/websocket/websocket_test.c | 11 | ||||
| -rw-r--r-- | tests/tcpsupp.c | 27 |
16 files changed, 30 insertions, 366 deletions
diff --git a/docs/man/CMakeLists.txt b/docs/man/CMakeLists.txt index e25ab977..4031889d 100644 --- a/docs/man/CMakeLists.txt +++ b/docs/man/CMakeLists.txt @@ -281,7 +281,6 @@ if (NNG_ENABLE_DOC) nng_stream_get nng_stream_recv nng_stream_send - nng_stream_set nng_stream_dialer_alloc nng_stream_dialer_close nng_stream_dialer_dial diff --git a/docs/man/libnng.3.adoc b/docs/man/libnng.3.adoc index c26913be..65ecac55 100644 --- a/docs/man/libnng.3.adoc +++ b/docs/man/libnng.3.adoc @@ -337,7 +337,6 @@ xref:nng_stream_listener.5.adoc[`nng_stream_listener`] objects. |xref:nng_stream_listener_set.3str.adoc[nng_stream_listener_set()]|set option on byte stream listener |xref:nng_stream_recv.3str.adoc[nng_stream_recv()]|receive from byte stream |xref:nng_stream_send.3str.adoc[nng_stream_send()]|send to byte stream -|xref:nng_stream_set.3str.adoc[nng_stream_set()]|set option on byte stream |=== === HTTP Support diff --git a/docs/man/nng_stream.5.adoc b/docs/man/nng_stream.5.adoc index 9144deb5..b3921e46 100644 --- a/docs/man/nng_stream.5.adoc +++ b/docs/man/nng_stream.5.adoc @@ -57,12 +57,10 @@ using xref:nng_stream_close.3str.adoc[`nng_stream_close()`]. Byte streams may, depending on the underlying technology, -support various +support various read-only xref:nng_options.5.adoc[options], which can be accessed using the -xref:nng_stream_get.3str.adoc[`nng_stream_get()`] and -xref:nng_stream_set.3str.adoc[`nng_stream_set()`] family of -functions. +xref:nng_stream_get.3str.adoc[`nng_stream_get()`]. == SEE ALSO @@ -75,6 +73,5 @@ xref:nng_stream_get.3str.adoc[nng_stream_get(3str)], xref:nng_stream_listener_accept.3str.adoc[nng_stream_listener_accept(3str)], xref:nng_stream_recv.3str.adoc[nng_stream_recv(3str)], xref:nng_stream_send.3str.adoc[nng_stream_send(3str)], -xref:nng_stream_set.3str.adoc[nng_stream_set(3str)], xref:nng_options.5.adoc[nng_options(5)], xref:nng.7.adoc[nng(7)], diff --git a/docs/man/nng_stream_get.3str.adoc b/docs/man/nng_stream_get.3str.adoc index 606fcc09..64ff626f 100644 --- a/docs/man/nng_stream_get.3str.adoc +++ b/docs/man/nng_stream_get.3str.adoc @@ -42,7 +42,7 @@ int nng_stream_get_uint64(nng_stream *s, const char *opt, uint64_t *valp); == DESCRIPTION -The `nng_stream_get()` functions are used to retrieve option values for the +The `nng_stream_get()` functions are used to retrieve option values for the xref:nng_stream.5.adoc[byte stream] _conn_. The actual options that may be retrieved in this way vary. @@ -138,7 +138,6 @@ This function returns 0 on success, and non-zero otherwise. [.text-left] xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_stream_set.3str.adoc[nng_stream_set(3str)], xref:nng_options.5.adoc[nng_options(5)], xref:nng_ipc_options.5.adoc[nng_ipc_options(5)], xref:nng_tcp_options.5.adoc[nng_tcp_options(5)], diff --git a/docs/man/nng_stream_set.3str.adoc b/docs/man/nng_stream_set.3str.adoc deleted file mode 100644 index 9386168e..00000000 --- a/docs/man/nng_stream_set.3str.adoc +++ /dev/null @@ -1,112 +0,0 @@ -= nng_stream_set(3str) -// -// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// Copyright 2019 Devolutions <info@devolutions.net> -// -// 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_stream_set - set option on byte stream - -== SYNOPSIS - -[source, c] ----- -#include <nng/nng.h> - -int nng_stream_set(nng_stream *s, const char *name, const void *data, size_t size); - -int nng_stream_set_bool(nng_stream *s, const char *opt, bool val); - -int nng_stream_set_int(nng_stream *s, const char *opt, int val); - -int nng_stream_set_ms(nng_stream *s, const char *opt, nng_duration val); - -int nng_stream_set_size(nng_stream *s, const char *opt, size_t val); - -int nng_stream_set_string(nng_stream *s, const char *opt, const char *val); - -int nng_stream_set_uint64(nng_stream *s, const char *opt, uint64_t val); - ----- - -== DESCRIPTION - -The `nng_stream_set()` functions are used to configure options for the -xref:nng_stream.5.adoc[byte stream] _s_. -The actual options that may be configured in this way vary, and are -specified by _opt_. -A number of them are documented in -xref:nng_options.5.adoc[nng_options(5)]. - -Additionally some transport-specific and protocol-specific options are -documented with the transports and protocols themselves. - -=== Forms - -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. - -`nng_stream_set()`:: -This function is untyped, and can be used to configure any arbitrary data. -The _val_ pointer addresses the data to copy, and _size_ is the -size of the objected located at _val_. -+ -TIP: It may be easier to use one of the typed forms of this function. - -`nng_stream_set_bool()`:: -This function is for options which take a Boolean (`bool`). - -`nng_stream_set_int()`:: -This function is for options which take an integer (`int`). - -`nng_stream_set_ms()`:: -This function is used to configure time durations (such as timeouts) using -the type -xref:nng_duration.5.adoc[`nng_duration`]. -The duration is an integer number of milliseconds. - -`nng_stream_set_size()`:: -This function is used to configure a size, typically for buffer sizes, -message maximum sizes, and similar options. - -`nng_stream_set_string()`:: -This function is used to pass configure a string. -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 each option -for details.) - -`nng_stream_set_uint64()`:: -This function is used to configure a 64-bit unsigned value/ -This is typically used for identifiers, network numbers, -and similar options. - -== RETURN VALUES - -This function returns 0 on success, and non-zero otherwise. - -== ERRORS - -[horizontal] -`NNG_ECLOSED`:: The connection is closed. -`NNG_EINVAL`:: Either _data_ or _size_ are invalid. -`NNG_ENOTSUP`:: The option is not supported. -`NNG_EREADONLY`:: The option may not be modified. - -== SEE ALSO - -[.text-left] -xref:nng_strerror.3.adoc[nng_strerror(3)], -xref:nng_stream_get.3str.adoc[nng_stream_get(3str)], -xref:nng_options.5.adoc[nng_options(5)], -xref:nng_ipc_options.5.adoc[nng_ipc_options(5)], -xref:nng_tcp_options.5.adoc[nng_tcp_options(5)], -xref:nng_tls_options.5.adoc[nng_tls_options(5)], -xref:nng_stream.5.adoc[nng_stream(5)] diff --git a/docs/ref/migrate/nng1.md b/docs/ref/migrate/nng1.md index 35224bb8..0e2c9a48 100644 --- a/docs/ref/migrate/nng1.md +++ b/docs/ref/migrate/nng1.md @@ -40,6 +40,8 @@ and similar has been removed. Instead configuration must be performed by allocat a `nng_tls_config` object, and then setting fields on it using the appropriate functions, after which it may be configured on a listener or dialer using the `NNG_OPT_TLS_CONFIG` option. +Note that TLS configuration is now available in `<nng/nng.h>`, rather than the supplemental header. + ## Option Functions The previously deprecated `nng_pipe_getopt_xxx` family of functions is removed. @@ -48,6 +50,17 @@ Applications should use `nng_pipe_get` and related functions instead. The socket option function families for `nng_getopt` and `nng_setopt` have been removed as well. In this case, use the `nng_socket_get` and `nng_socket_set` functions as appropriate. +The `_getopt` and `_setopt` functions for contexts, listeners, and dialers are no longer +present. Simply changing `_getopt` to `_get` or `_setopt` to `_set` in the function name +should be sufficient in most cases. + +## Stream Options + +The ability to set options on streams after they have been created is no longer present. +(It turns out that this was not very useful.) All functions `nng_stream_set_xxx` are removed. +For tuning the `NNG_OPT_TCP_NODELAY` or similar properties, set the option on the listener +or dialer that creates the stream instead. + ## Transport Options A number of transport options can no longer be set on the socket. Instead these diff --git a/include/nng/nng.h b/include/nng/nng.h index 43d293dc..fff3db37 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -1151,14 +1151,6 @@ NNG_DECL int nng_stream_get_uint64(nng_stream *, const char *, uint64_t *); NNG_DECL int nng_stream_get_string(nng_stream *, const char *, char **); NNG_DECL int nng_stream_get_ptr(nng_stream *, const char *, void **); NNG_DECL int nng_stream_get_addr(nng_stream *, const char *, nng_sockaddr *); -NNG_DECL int nng_stream_set(nng_stream *, const char *, const void *, size_t); -NNG_DECL int nng_stream_set_bool(nng_stream *, const char *, bool); -NNG_DECL int nng_stream_set_int(nng_stream *, const char *, int); -NNG_DECL int nng_stream_set_ms(nng_stream *, const char *, nng_duration); -NNG_DECL int nng_stream_set_size(nng_stream *, const char *, size_t); -NNG_DECL int nng_stream_set_uint64(nng_stream *, const char *, uint64_t); -NNG_DECL int nng_stream_set_string(nng_stream *, const char *, const char *); -NNG_DECL int nng_stream_set_ptr(nng_stream *, const char *, void *); NNG_DECL int nng_stream_dialer_alloc(nng_stream_dialer **, const char *); NNG_DECL int nng_stream_dialer_alloc_url( diff --git a/src/core/stream.c b/src/core/stream.c index fce1e45e..f1cf6301 100644 --- a/src/core/stream.c +++ b/src/core/stream.c @@ -146,13 +146,6 @@ nni_stream_get( return (s->s_get(s, nm, data, szp, t)); } -int -nni_stream_set( - nng_stream *s, const char *nm, const void *data, size_t sz, nni_type t) -{ - return (s->s_set(s, nm, data, sz, t)); -} - void nng_stream_dialer_close(nng_stream_dialer *d) { @@ -465,55 +458,6 @@ nng_stream_listener_get_addr( } int -nng_stream_set(nng_stream *s, const char *n, const void *v, size_t sz) -{ - return (nni_stream_set(s, n, v, sz, NNI_TYPE_OPAQUE)); -} - -int -nng_stream_set_int(nng_stream *s, const char *n, int v) -{ - return (nni_stream_set(s, n, &v, sizeof(v), NNI_TYPE_INT32)); -} - -int -nng_stream_set_bool(nng_stream *s, const char *n, bool v) -{ - return (nni_stream_set(s, n, &v, sizeof(v), NNI_TYPE_BOOL)); -} - -int -nng_stream_set_size(nng_stream *s, const char *n, size_t v) -{ - return (nni_stream_set(s, n, &v, sizeof(v), NNI_TYPE_SIZE)); -} - -int -nng_stream_set_uint64(nng_stream *s, const char *n, uint64_t v) -{ - return (nni_stream_set(s, n, &v, sizeof(v), NNI_TYPE_UINT64)); -} - -int -nng_stream_set_ms(nng_stream *s, const char *n, nng_duration v) -{ - return (nni_stream_set(s, n, &v, sizeof(v), NNI_TYPE_DURATION)); -} - -int -nng_stream_set_ptr(nng_stream *s, const char *n, void *v) -{ - return (nni_stream_set(s, n, &v, sizeof(v), NNI_TYPE_POINTER)); -} - -int -nng_stream_set_string(nng_stream *s, const char *n, const char *v) -{ - return (nni_stream_set( - s, n, v, v == NULL ? 0 : strlen(v) + 1, NNI_TYPE_STRING)); -} - -int nng_stream_dialer_set( nng_stream_dialer *d, const char *n, const void *v, size_t sz) { diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c index 2494b05e..74b3371b 100644 --- a/src/platform/posix/posix_tcpconn.c +++ b/src/platform/posix/posix_tcpconn.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2019 Devolutions <info@devolutions.net> // @@ -42,7 +42,7 @@ tcp_dowrite(nni_tcp_conn *c) int n; int niov; unsigned naiov; - nni_iov * aiov; + nni_iov *aiov; struct msghdr hdr; struct iovec iovec[16]; @@ -111,7 +111,7 @@ tcp_doread(nni_tcp_conn *c) int n; int niov; unsigned naiov; - nni_iov * aiov; + nni_iov *aiov; struct iovec iovec[16]; nni_aio_get_iov(aio, &naiov, &aiov); @@ -165,7 +165,7 @@ static void tcp_error(void *arg, int err) { nni_tcp_conn *c = arg; - nni_aio * aio; + nni_aio *aio; nni_mtx_lock(&c->mtx); while (((aio = nni_list_first(&c->readq)) != NULL) || @@ -337,7 +337,7 @@ tcp_recv(void *arg, nni_aio *aio) static int tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) { - nni_tcp_conn * c = arg; + nni_tcp_conn *c = arg; struct sockaddr_storage ss; socklen_t len = sizeof(ss); int fd = nni_posix_pfd_fd(c->pfd); @@ -356,7 +356,7 @@ tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) static int tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) { - nni_tcp_conn * c = arg; + nni_tcp_conn *c = arg; struct sockaddr_storage ss; socklen_t len = sizeof(ss); int fd = nni_posix_pfd_fd(c->pfd); @@ -373,46 +373,6 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) } static int -tcp_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - int fd; - bool b; - int val; - int rv; - - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (c == NULL)) { - return (rv); - } - val = b ? 1 : 0; - fd = nni_posix_pfd_fd(c->pfd); - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) != 0) { - return (nni_plat_errno(errno)); - } - return (0); -} - -static int -tcp_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - int fd; - bool b; - int val; - int rv; - - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (c == NULL)) { - return (rv); - } - val = b ? 1 : 0; - fd = nni_posix_pfd_fd(c->pfd); - if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)) != 0) { - return (nni_plat_errno(errno)); - } - return (0); -} - -static int tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -454,12 +414,10 @@ static const nni_option tcp_options[] = { { .o_name = NNG_OPT_TCP_NODELAY, .o_get = tcp_get_nodelay, - .o_set = tcp_set_nodelay, }, { .o_name = NNG_OPT_TCP_KEEPALIVE, .o_get = tcp_get_keepalive, - .o_set = tcp_set_keepalive, }, { .o_name = NULL, diff --git a/src/platform/windows/win_tcpconn.c b/src/platform/windows/win_tcpconn.c index eaae822a..3f3acd17 100644 --- a/src/platform/windows/win_tcpconn.c +++ b/src/platform/windows/win_tcpconn.c @@ -305,43 +305,6 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) } static int -tcp_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - bool val; - BOOL b; - int rv; - if ((rv = nni_copyin_bool(&val, buf, sz, t)) != 0) { - return (rv); - } - b = val ? TRUE : FALSE; - if (setsockopt( - c->s, IPPROTO_TCP, TCP_NODELAY, (void *) &b, sizeof(b)) != 0) { - return (nni_win_error(WSAGetLastError())); - } - return (0); -} - -static int -tcp_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - bool val; - BOOL b; - int rv; - - if ((rv = nni_copyin_bool(&val, buf, sz, t)) != 0) { - return (rv); - } - b = val ? TRUE : FALSE; - if (setsockopt( - c->s, SOL_SOCKET, SO_KEEPALIVE, (void *) &b, sizeof(b)) != 0) { - return (nni_win_error(WSAGetLastError())); - } - return (0); -} - -static int tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { nni_tcp_conn *c = arg; @@ -381,12 +344,10 @@ static const nni_option tcp_options[] = { { .o_name = NNG_OPT_TCP_NODELAY, .o_get = tcp_get_nodelay, - .o_set = tcp_set_nodelay, }, { .o_name = NNG_OPT_TCP_KEEPALIVE, .o_get = tcp_get_keepalive, - .o_set = tcp_set_keepalive, }, { .o_name = NULL, diff --git a/src/supplemental/http/http_api.h b/src/supplemental/http/http_api.h index 70a43432..813f9fe6 100644 --- a/src/supplemental/http/http_api.h +++ b/src/supplemental/http/http_api.h @@ -1,5 +1,5 @@ // -// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2019 Devolutions <info@devolutions.net> // @@ -102,8 +102,6 @@ extern void nni_http_conn_close(nni_http_conn *); extern void nni_http_conn_fini(nni_http_conn *); extern int nni_http_conn_getopt( nni_http_conn *, const char *, void *, size_t *, nni_type); -extern int nni_http_conn_setopt( - nni_http_conn *, const char *, const void *, size_t, nni_type); // Reading messages -- the caller must supply a preinitialized (but otherwise // idle) message. We recommend the caller store this in the aio's user data. diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c index 03d1a1f5..33ed70bb 100644 --- a/src/supplemental/http/http_conn.c +++ b/src/supplemental/http/http_conn.c @@ -647,21 +647,6 @@ nni_http_conn_getopt( return (rv); } -int -nni_http_conn_setopt(nni_http_conn *conn, const char *name, const void *buf, - size_t sz, nni_type t) -{ - int rv; - nni_mtx_lock(&conn->mtx); - if (conn->closed) { - rv = NNG_ECLOSED; - } else { - rv = nni_stream_set(conn->sock, name, buf, sz, t); - } - nni_mtx_unlock(&conn->mtx); - return (rv); -} - void nni_http_conn_fini(nni_http_conn *conn) { diff --git a/src/supplemental/tls/tls_common.c b/src/supplemental/tls/tls_common.c index 02ca1442..139460f5 100644 --- a/src/supplemental/tls/tls_common.c +++ b/src/supplemental/tls/tls_common.c @@ -640,21 +640,6 @@ static const nni_option tls_options[] = { }; static int -tls_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t) -{ - tls_conn *conn = arg; - int rv; - nng_stream *tcp; - - tcp = (conn != NULL) ? conn->tcp : NULL; - - if ((rv = nni_stream_set(tcp, name, buf, sz, t)) != NNG_ENOTSUP) { - return (rv); - } - return (nni_setopt(tls_options, name, conn, buf, sz, t)); -} - -static int tls_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t) { tls_conn *conn = arg; @@ -713,7 +698,6 @@ tls_alloc(tls_conn **conn_p, nng_tls_config *cfg, nng_aio *user_aio) conn->stream.s_send = tls_send; conn->stream.s_recv = tls_recv; conn->stream.s_get = tls_get; - conn->stream.s_set = tls_set; nng_tls_config_hold(cfg); *conn_p = conn; diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c index daecbb31..ce733c84 100644 --- a/src/supplemental/websocket/websocket.c +++ b/src/supplemental/websocket/websocket.c @@ -179,7 +179,6 @@ static void ws_str_close(void *); static void ws_str_send(void *, nng_aio *); static void ws_str_recv(void *, nng_aio *); static int ws_str_get(void *, const char *, void *, size_t *, nni_type); -static int ws_str_set(void *, const char *, const void *, size_t, nni_type); static void ws_listener_close(void *); static void ws_listener_free(void *); @@ -1461,7 +1460,6 @@ ws_init(nni_ws **wsp) ws->ops.s_send = ws_str_send; ws->ops.s_recv = ws_str_recv; ws->ops.s_get = ws_str_get; - ws->ops.s_set = ws_str_set; ws->fragsize = 1 << 20; // we won't send a frame larger than this *wsp = ws; @@ -2869,33 +2867,6 @@ static const nni_option ws_options[] = { }; static int -ws_str_set(void *arg, const char *nm, const void *buf, size_t sz, nni_type t) -{ - nni_ws *ws = arg; - int rv; - - // Headers can only be set. - nni_mtx_lock(&ws->mtx); - if (ws->closed) { - nni_mtx_unlock(&ws->mtx); - return (NNG_ECLOSED); - } - nni_mtx_unlock(&ws->mtx); - rv = nni_http_conn_setopt(ws->http, nm, buf, sz, t); - if (rv == NNG_ENOTSUP) { - rv = nni_setopt(ws_options, nm, ws, buf, sz, t); - } - if (rv == NNG_ENOTSUP) { - if (startswith(nm, NNG_OPT_WS_REQUEST_HEADER) || - startswith(nm, NNG_OPT_WS_RESPONSE_HEADER)) { - return (NNG_EREADONLY); - } - } - - return (rv); -} - -static int ws_get_req_header( nni_ws *ws, const char *nm, void *buf, size_t *szp, nni_type t) { diff --git a/src/supplemental/websocket/websocket_test.c b/src/supplemental/websocket/websocket_test.c index edd3d609..1b48aff5 100644 --- a/src/supplemental/websocket/websocket_test.c +++ b/src/supplemental/websocket/websocket_test.c @@ -175,26 +175,15 @@ test_websocket_conn_props(void) NUTS_TRUE(sa1.s_in.sa_addr == sa2.s_in.sa_addr); NUTS_TRUE(sa1.s_in.sa_port == sa2.s_in.sa_port); - on = true; - NUTS_PASS(nng_stream_set_bool(c1, NNG_OPT_TCP_NODELAY, on)); - NUTS_PASS(nng_stream_set_bool(c2, NNG_OPT_TCP_NODELAY, on)); - - NUTS_PASS(nng_stream_set_bool(c1, NNG_OPT_TCP_KEEPALIVE, on)); - NUTS_PASS(nng_stream_set_bool(c2, NNG_OPT_TCP_KEEPALIVE, on)); - NUTS_FAIL(nng_stream_set_string(c1, NNG_OPT_TCP_KEEPALIVE, "nope"), - NNG_EBADTYPE); - on = false; sz = sizeof(on); NUTS_PASS(nng_stream_get(c1, NNG_OPT_TCP_NODELAY, &on, &sz)); NUTS_TRUE(sz == sizeof(on)); NUTS_TRUE(on == true); - on = false; sz = sizeof(on); NUTS_PASS(nng_stream_get(c2, NNG_OPT_TCP_KEEPALIVE, &on, &sz)); NUTS_TRUE(sz == sizeof(on)); - NUTS_TRUE(on == true); NUTS_FAIL( nng_stream_get_size(c1, NNG_OPT_TCP_NODELAY, &sz), NNG_EBADTYPE); diff --git a/tests/tcpsupp.c b/tests/tcpsupp.c index 9117c15b..ac1ed200 100644 --- a/tests/tcpsupp.c +++ b/tests/tcpsupp.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -17,7 +17,7 @@ TestMain("Supplemental TCP", { Convey("We can create a dialer and listener", { - nng_stream_dialer * d = NULL; + nng_stream_dialer *d = NULL; nng_stream_listener *l = NULL; Reset({ nng_stream_listener_free(l); @@ -46,9 +46,9 @@ TestMain("Supplemental TCP", { So(memcmp(&sa.s_in.sa_addr, ip, 4) == 0); Convey("We can dial it", { - nng_aio * daio = NULL; - nng_aio * laio = NULL; - nng_aio * maio = NULL; + nng_aio *daio = NULL; + nng_aio *laio = NULL; + nng_aio *maio = NULL; nng_stream *c1 = NULL; nng_stream *c2 = NULL; @@ -93,8 +93,8 @@ TestMain("Supplemental TCP", { So(c2 != NULL); Convey("They exchange messages", { - nng_aio * aio1; - nng_aio * aio2; + nng_aio *aio1; + nng_aio *aio2; nng_iov iov; nng_sockaddr sa2; char buf1[5]; @@ -112,18 +112,6 @@ TestMain("Supplemental TCP", { nng_aio_free(aio2); }); - on = true; - So(nng_stream_set(c1, - NNG_OPT_TCP_NODELAY, &on, - sizeof(on)) == 0); - So(nng_stream_set(c2, - NNG_OPT_TCP_NODELAY, &on, - sizeof(on)) == 0); - - So(nng_stream_set(c1, - NNG_OPT_TCP_KEEPALIVE, &on, - sizeof(on)) == 0); - on = false; sz = sizeof(on); So(nng_stream_get(c1, @@ -138,7 +126,6 @@ TestMain("Supplemental TCP", { NNG_OPT_TCP_KEEPALIVE, &on, &sz) == 0); So(sz == sizeof(on)); - So(on == true); // This relies on send completing for // for just 5 bytes, and on recv doing |
