...
m_LocalSocket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
...
res = bind(m_LocalSocket, reinterpret_cast<sockaddr *>(&m_LocalAddress), sizeof(m_LocalAddress));
...
res = listen(m_LocalSocket, SOMAXCONN);
...
Connect->GetInSocket() = WSAAccept(m_LocalSocket,
reinterpret_cast<sockaddr *>(&(Connect->GetRemAddr())), &res, 0, 0);
if (Connect->GetInSocket() == INVALID_SOCKET)
{
delete Connect;
if(WSAGetLastError() == WSAEWOULDBLOCK )
{
...
Асинхронные сокеты
Код:
ЧЕ WSAAccept не отдает управления?
MSDN:
A socket in nonblocking mode (blocking) fails with the error WSAEWOULDBLOCK when an application calls WSAAccept and no connections are pending on the queue. After WSAAccept succeeds and returns a new socket handle, the accepted socket cannot be used to accept any more connections. The original socket remains open and listens for new connection requests.