void OnAccept(const AsyncResultPtr &asyncResult) { try { SocketPtr listenSocket = asyncResult->asyncState; SocketPtr acceptSocket = listenSocket->EndAccept(asyncResult); acceptSocket->BeginReceive(BufferPtr(8192, NoRebindTag()), &OnReceive, acceptSocket); listenSocket->BeginAccept(&OnAccept, listenSocket); } catch (const std::exception &) { } }
int main() { try { SocketPtr listenSocket; listenSocket->Bind(7777); listenSocket->Listen(); listenSocket->BeginAccept(&OnAccept, listenSocket); Sleep(INFINITE); } catch (const std::exception &) { } }