summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Network.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-08-12 11:27:34 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-08-12 11:27:34 -0230
commit8cf90068d315621cc645ea11342e0404a8d15f67 (patch)
tree95a642ca1b8435f9c3765b11331fcb568be76238 /cpp/src/Ice/Network.cpp
parentFix interrupt test on OSX. (diff)
downloadice-8cf90068d315621cc645ea11342e0404a8d15f67.tar.bz2
ice-8cf90068d315621cc645ea11342e0404a8d15f67.tar.xz
ice-8cf90068d315621cc645ea11342e0404a8d15f67.zip
ICE-5492 Tcp Loopback Fast Path for C#/C++ on Windows
Diffstat (limited to 'cpp/src/Ice/Network.cpp')
-rw-r--r--cpp/src/Ice/Network.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index d329368612e..87aa299e395 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -57,6 +57,13 @@ extern "C"
}
#endif
+#ifdef _WIN32
+# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x602)
+# include <mstcpip.h>
+# define HAS_LOOPBACK_FAST_PATH 1
+# endif
+#endif
+
using namespace std;
using namespace Ice;
using namespace IceInternal;
@@ -141,6 +148,28 @@ setKeepAlive(SOCKET fd)
}
#endif
+#ifdef HAS_LOOPBACK_FAST_PATH
+void
+setTcpLoopbackFastPath(SOCKET fd)
+{
+ int OptionValue = 1;
+ DWORD NumberOfBytesReturned = 0;
+ int status =
+ WSAIoctl(fd, SIO_LOOPBACK_FAST_PATH, &OptionValue, sizeof(OptionValue), NULL, 0, &NumberOfBytesReturned, 0, 0);
+ if(status == SOCKET_ERROR)
+ {
+ DWORD LastError = ::GetLastError();
+ if(LastError != WSAEOPNOTSUPP)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+}
+#endif
+
#ifdef ICE_OS_WINRT
SOCKET
createSocketImpl(bool udp, int)
@@ -187,6 +216,9 @@ createSocketImpl(bool udp, int family)
{
setTcpNoDelay(fd);
setKeepAlive(fd);
+#ifdef HAS_LOOPBACK_FAST_PATH
+ setTcpLoopbackFastPath(fd);
+#endif
}
return fd;