diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-11-15 17:47:54 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-11-15 17:47:54 -0800 |
| commit | 249932f3a208260f6b9c99d778b22d51cfabe87b (patch) | |
| tree | 4fd4826127e9c225d5232c39d4ae1db89b539689 /src/core/platform.h | |
| parent | eb328da56c3fc7167b536dcb206df0abb0f4a9b9 (diff) | |
| download | nng-249932f3a208260f6b9c99d778b22d51cfabe87b.tar.gz nng-249932f3a208260f6b9c99d778b22d51cfabe87b.tar.bz2 nng-249932f3a208260f6b9c99d778b22d51cfabe87b.zip | |
fixes #1071 tran_chkopt can be cleaned up
This is a sweeping cleanup of the transport logic around options,
and also harmonizes the names used when setting or getting options.
Additionally, legacy methods are now moved into a separate file and
can be elided via CMake or a preprocessor define.
Fundamentally, the ability to set to transport options via the socket
is deprecated; there are numerous problems with this and my earlier
approaches to deal with this have been somewhat misguided. Further
these approaches will not work with future protocol work that is
planned (were some options need to be negotiated with peers at the
time of connection establishment.)
Documentation has been updated to reflect this. The test suites still
make rather broad use of the older APIs, and will be converted later.
Diffstat (limited to 'src/core/platform.h')
| -rw-r--r-- | src/core/platform.h | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/core/platform.h b/src/core/platform.h index 704e338d..35d42339 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -280,8 +280,8 @@ extern int nni_tcp_dialer_init(nni_tcp_dialer **); extern void nni_tcp_dialer_fini(nni_tcp_dialer *); // nni_tcp_dialer_close closes the dialer. -// Further operations on it should return NNG_ECLOSED. Any in-progress -// connection will be aborted. +// Further operations on it should return NNG_ECLOSED. +// Any in-progress connection will be aborted. extern void nni_tcp_dialer_close(nni_tcp_dialer *); // nni_tcp_dial attempts to create an outgoing connection, @@ -289,16 +289,12 @@ extern void nni_tcp_dialer_close(nni_tcp_dialer *); // output will be an nni_tcp_conn * associated with the remote server. extern void nni_tcp_dial(nni_tcp_dialer *, const nng_sockaddr *, nni_aio *); -// nni_tcp_dialer_getopt gets an option from the dialer. -extern int nni_tcp_dialer_setopt( +// nni_tcp_dialer_set sets an option on the dialer. +extern int nni_tcp_dialer_set( nni_tcp_dialer *, const char *, const void *, size_t, nni_type); -// nni_tcp_dialer_setopt sets an option on the dialer. There is special -// support for NNG_OPT_LOCADDR, which will be the source address (if legal) -// for new connections, except that the port will be ignored. The -// NNG_OPT_TCP_NODELAY and NNG_OPT_TCP_KEEPALIVE options work to set the -// initial values of those options on newly created connections. -extern int nni_tcp_dialer_getopt( +// nni_tcp_dialer_get gets an option on the dialer. +extern int nni_tcp_dialer_get( nni_tcp_dialer *, const char *, void *, size_t *, nni_type); // nni_tcp_listener_init creates a new listener object, unbound. @@ -321,14 +317,14 @@ extern int nni_tcp_listener_listen(nni_tcp_listener *, const nni_sockaddr *); // associated with the remote peer. extern void nni_tcp_listener_accept(nni_tcp_listener *, nni_aio *); -// nni_tcp_listener_getopt gets an option from the listener. -extern int nni_tcp_listener_setopt( +// nni_tcp_listener_set sets an option on the listener. +extern int nni_tcp_listener_set( nni_tcp_listener *, const char *, const void *, size_t, nni_type); -// nni_tcp_listener_setopt sets an option on the listener. The most common +// nni_tcp_listener_get gets an option from the listener. The most common // use for this is to retrieve the setting of the NNG_OPT_TCP_LOCADDR // address after binding to wild card port (0). -extern int nni_tcp_listener_getopt( +extern int nni_tcp_listener_get( nni_tcp_listener *, const char *, void *, size_t *, nni_type); // nni_resolv_ip resolves a DNS host and service name asynchronously. @@ -339,8 +335,8 @@ extern int nni_tcp_listener_getopt( // connect(). The host part may be NULL only if passive is true. // Symbolic service names will be looked up assuming SOCK_STREAM, so // they may not work with UDP. -extern void nni_resolv_ip(const char *, const char *, int, bool, - nng_sockaddr *sa, nni_aio *); +extern void nni_resolv_ip( + const char *, const char *, int, bool, nng_sockaddr *sa, nni_aio *); // nni_parse_ip parses an IP address, without a port. extern int nni_parse_ip(const char *, nng_sockaddr *); @@ -361,7 +357,6 @@ typedef struct nni_ipc_listener nni_ipc_listener; // be stubs that just return NNG_ENOTSUP. extern int nni_ipc_dialer_alloc(nng_stream_dialer **, const nng_url *); extern int nni_ipc_listener_alloc(nng_stream_listener **, const nng_url *); -extern int nni_ipc_checkopt(const char *, const void *, size_t, nni_type); // // UDP support. UDP is not connection oriented, and only has the notion |
