set TCP_NODELAY on the mpd tcp socket

master
Andrzej Rybczak 12 years ago
parent 40ef9070af
commit 37195d6bea
  1. 2
      configure.ac
  2. 6
      src/ncmpcpp.cpp

@ -185,7 +185,7 @@ AC_CHECK_LIB(regex, regcomp, LDFLAGS="$LDFLAGS -lregex", )
dnl ================================ dnl ================================
dnl = checking for various headers = dnl = checking for various headers =
dnl ================================ dnl ================================
AC_CHECK_HEADERS([dirent.h regex.h], , AC_MSG_ERROR(vital headers missing)) AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled)) AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
dnl ============================== dnl ==============================

@ -22,6 +22,8 @@
#include <clocale> #include <clocale>
#include <csignal> #include <csignal>
#include <cstring> #include <cstring>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <boost/locale.hpp> #include <boost/locale.hpp>
#include <iostream> #include <iostream>
@ -177,6 +179,10 @@ int main(int argc, char **argv)
myPlaylist->main().highlight(curr_pos); myPlaylist->main().highlight(curr_pos);
} }
// Set TCP_NODELAY on the tcp socket as this significantly speeds up operations.
int flag = 1;
setsockopt(Mpd.GetFD(), IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
// go to startup screen // go to startup screen
if (Config.startup_screen_type != myScreen->type()) if (Config.startup_screen_type != myScreen->type())
toScreen(Config.startup_screen_type)->switchTo(); toScreen(Config.startup_screen_type)->switchTo();

Loading…
Cancel
Save