diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-26 13:53:40 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-26 13:53:40 -0700 |
| commit | 3de2b56557c80b310341c423492bd8ba895c1abe (patch) | |
| tree | 897815f4d9aa30d8c40cbed4c5fec4088d555fda /src/platform/posix/posix_pipedesc.c | |
| parent | 492bfcc90d4b80842b024201cc1e4526404128b4 (diff) | |
| download | nng-3de2b56557c80b310341c423492bd8ba895c1abe.tar.gz nng-3de2b56557c80b310341c423492bd8ba895c1abe.tar.bz2 nng-3de2b56557c80b310341c423492bd8ba895c1abe.zip | |
fixes #105 Want NNG_OPT_TCP_NODELAY option
fixes #106 TCP keepalive tuning
Diffstat (limited to 'src/platform/posix/posix_pipedesc.c')
| -rw-r--r-- | src/platform/posix/posix_pipedesc.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/platform/posix/posix_pipedesc.c b/src/platform/posix/posix_pipedesc.c index 72251372..f9cbb94b 100644 --- a/src/platform/posix/posix_pipedesc.c +++ b/src/platform/posix/posix_pipedesc.c @@ -16,6 +16,8 @@ #include <errno.h> #include <fcntl.h> +#include <netinet/in.h> +#include <netinet/tcp.h> #include <poll.h> #include <stdbool.h> #include <stdlib.h> @@ -335,6 +337,30 @@ nni_posix_pipedesc_sockname(nni_posix_pipedesc *pd, nni_sockaddr *sa) } int +nni_posix_pipedesc_set_nodelay(nni_posix_pipedesc *pd, bool nodelay) +{ + int val = nodelay ? 1 : 0; + + if (setsockopt(pd->node.fd, IPPROTO_TCP, TCP_NODELAY, &val, + sizeof(val)) != 0) { + return (nni_plat_errno(errno)); + } + return (0); +} + +int +nni_posix_pipedesc_set_keepalive(nni_posix_pipedesc *pd, bool keep) +{ + int val = keep ? 1 : 0; + + if (setsockopt(pd->node.fd, SOL_SOCKET, SO_KEEPALIVE, &val, + sizeof(val)) != 0) { + return (nni_plat_errno(errno)); + } + return (0); +} + +int nni_posix_pipedesc_init(nni_posix_pipedesc **pdp, int fd) { nni_posix_pipedesc *pd; |
