diff --git a/aucat/listen.c b/aucat/listen.c index c0cc63a..31414b7 100644 --- a/aucat/listen.c +++ b/aucat/listen.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -178,7 +179,7 @@ listen_revents(struct file *file, struct pollfd *pfd) struct listen *f = (struct listen *)file; struct sockaddr caddr; socklen_t caddrlen; - int sock; + int sock, opt; if (pfd->revents & POLLIN) { caddrlen = sizeof(caddrlen); @@ -193,6 +194,15 @@ listen_revents(struct file *file, struct pollfd *pfd) close(sock); return 0; } + if (f->path == NULL) { + opt = 1; + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, + &opt, sizeof(int)) < 0) { + perror("setsockopt"); + close(sock); + return 0; + } + } if (sock_new(&sock_ops, sock) == NULL) { close(sock); return 0; diff --git a/libsndio/aucat.c b/libsndio/aucat.c index 7fce8bb..9cc059f 100644 --- a/libsndio/aucat.c +++ b/libsndio/aucat.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -316,7 +317,7 @@ bad_gen: int aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio) { - int s, error; + int s, error, opt; struct addrinfo *ailist, *ai, aihints; unsigned port; char serv[NI_MAXSERV]; @@ -356,6 +357,12 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio) freeaddrinfo(ailist); if (s < 0) return 0; + opt = 1; + if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int)) < 0) { + DPERROR("setsockopt"); + close(s); + return 0; + } hdl->fd = s; return 1; }