aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/websocketasio.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-03-08 08:59:29 +0100
committerPer Larsson <[email protected]>2022-03-08 08:59:29 +0100
commit8ce0478145e887088c1988d01847ef0b73be199d (patch)
tree978fc64128426b6d4f91899d5dbe6538c1167a46 /zenhttp/websocketasio.cpp
parentInitial attempt of a streaming websocket API. (diff)
downloadzen-8ce0478145e887088c1988d01847ef0b73be199d.tar.xz
zen-8ce0478145e887088c1988d01847ef0b73be199d.zip
Added streaming version of GetCacheRecords.
Diffstat (limited to 'zenhttp/websocketasio.cpp')
-rw-r--r--zenhttp/websocketasio.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/zenhttp/websocketasio.cpp b/zenhttp/websocketasio.cpp
index 5407f8bc6..5a47d0ea9 100644
--- a/zenhttp/websocketasio.cpp
+++ b/zenhttp/websocketasio.cpp
@@ -27,6 +27,10 @@ ZEN_THIRD_PARTY_INCLUDES_START
#include <asio.hpp>
ZEN_THIRD_PARTY_INCLUDES_END
+#if ZEN_PLATFORM_WINDOWS
+# include <mstcpip.h>
+#endif
+
namespace zen::websocket {
using namespace std::literals;
@@ -654,6 +658,25 @@ WsServer::Run()
m_Acceptor->set_option(asio::socket_base::receive_buffer_size(ReceiveBufferSize));
m_Acceptor->set_option(asio::socket_base::send_buffer_size(SendBufferSize));
+#if ZEN_PLATFORM_WINDOWS
+ // On Windows, loopback connections can take advantage of a faster code path optionally with this flag.
+ // This must be used by both the client and server side, and is only effective in the absence of
+ // Windows Filtering Platform (WFP) callouts which can be installed by security software.
+ // https://docs.microsoft.com/en-us/windows/win32/winsock/sio-loopback-fast-path
+ SOCKET NativeSocket = m_Acceptor->native_handle();
+ int LoopbackOptionValue = 1;
+ DWORD OptionNumberOfBytesReturned = 0;
+ WSAIoctl(NativeSocket,
+ SIO_LOOPBACK_FAST_PATH,
+ &LoopbackOptionValue,
+ sizeof(LoopbackOptionValue),
+ NULL,
+ 0,
+ &OptionNumberOfBytesReturned,
+ 0,
+ 0);
+#endif
+
asio::error_code Ec;
m_Acceptor->bind(asio::ip::tcp::endpoint(asio::ip::address_v6::any(), m_Options.Port), Ec);