acl/lib_fiber/samples-gui/EchoServer/FiberServer.cpp

29 lines
397 B
C++
Raw Normal View History

2021-09-13 16:55:27 +08:00
#include "pch.h"
#include "FiberClient.h"
#include "FiberServer.h"
CFiberServer::CFiberServer(SOCKET sock)
: m_sock(sock)
{
}
CFiberServer::~CFiberServer(void)
{
closesocket(m_sock);
}
void CFiberServer::run(void)
{
while (true) {
SOCKET s = accept(m_sock, NULL, NULL);
if (s == INVALID_SOCKET) {
break;
}
acl::fiber* fb = new CFiberClient(s);
fb->start();
}
delete this;
}