NetStream/NetAddress/NetDevice/NetPacketHeaderMap and EterBase/cipher.cpp are mechanical copies. The winsock shim maps Winsock onto BSD sockets and keeps the Winsock semantics CNetworkStream relies on: select ignores nfds, a socket whose connect failed is not writable (40250 times out instead), EINPROGRESS reads as WSAEWOULDBLOCK, and SIGPIPE is ignored. port.net covers loopback connect, send/recv, peer close, the refused connect timeout and the client/server key agreement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
467 B
C++
41 lines
467 B
C++
#include "StdAfx.h"
|
|
#include "NetDevice.h"
|
|
|
|
CNetworkDevice::CNetworkDevice()
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
CNetworkDevice::~CNetworkDevice()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
void CNetworkDevice::Initialize()
|
|
{
|
|
m_isWSA=false;
|
|
}
|
|
|
|
void CNetworkDevice::Destroy()
|
|
{
|
|
if (m_isWSA)
|
|
{
|
|
WSACleanup();
|
|
m_isWSA=false;
|
|
}
|
|
}
|
|
|
|
bool CNetworkDevice::Create()
|
|
{
|
|
Destroy();
|
|
|
|
Initialize();
|
|
|
|
WSADATA wsaData;
|
|
if (WSAStartup(MAKEWORD(1, 1), &wsaData)!=0)
|
|
return false;
|
|
|
|
m_isWSA=true;
|
|
|
|
return true;
|
|
} |