mirror of https://github.com/ericonr/sndio.git
use TCP_NODELAY
This commit is contained in:
parent
a583ebc5d9
commit
32a1e3d36e
|
@ -21,6 +21,7 @@
|
|||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <err.h>
|
||||
|
@ -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;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue