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