Esempio n. 1
0
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 &) {
	}
}
Esempio n. 2
0
int main()
{
	try {
		SocketPtr listenSocket;
		listenSocket->Bind(7777);
		listenSocket->Listen();
		listenSocket->BeginAccept(&OnAccept, listenSocket);
		Sleep(INFINITE);
	} catch (const std::exception &) {
	}
}