我目前在分布式多进程应用程序中搜索一些性能问题!
这就是我想尝试快速环回套接字的原因 SIO_LOOPBACK_FAST_PATH descreption和msdn desc.
这是我打开服务器套接字的代码片段:
TcpipSocket::TcpipSocket(FullIPAddress const& address)
: m_Port(address.m_Port)
, m_IPAddress(address.m_Address)
, m_Socket(INVALID_SOCKET)
{
if (0 == ms_NumberOfInstances)
{
initNetwork(NULL); // here i call the WSAStartup function
}
m_Socket = ::socket(TCPSocketFamily, TCPSocketType, TCPProtocol);
if (INVALID_SOCKET == m_Socket)
{
throwException(ConstrName);
}
else
{
// this is the code to enable the FAST Loopback Sockets see [1]
int OptionValue =1;
DWORD NumberOfBytesReturned =0;
int status=::WSAIoctl(m_Socket,
SIO_LOOPBACK_FAST_PATH,
&OptionValue,
sizeof(OptionValue),
NULL,
0,
&NumberOfBytesReturned,
0,
0);
if (SOCKET_ERROR == status)
{
DWORD LastError = ::WSAGetLastError();
if (WSAEOPNOTSUPP == LastError)
{
std::ostringstream out;
out << "This system is not Windows Windows Server 2012/Windows 8, \n";
out << "and the call is not supported.\n";
out << "ErrorNumber: "<< LastError;
throwException(out.str().c_str());
}
else
{
std::ostringstream out;
out << "TcpipSocket::Loopback Fastpath WSAIoctl failed: ";
out << "\nErrorNumber: "<< LastError;
throwException(out.str().c_str());
}
}
}
}
问题:我总是收到错误 WSAEOPNOTSUPP 在所有更新的Windows 8 64位上运行示例..
我错过了什么?关于这个例子,它应该直接工作吗?
代码使用VS2012在win 7 x64上编写 我使用平台工具集“Visual Studio 2012(v110)”