2
3
4
5
21
22
23 m_AcceptSocket.Create();
24 m_AcceptSocket.SetReuseAddress(
true);
25 m_AcceptSocket.BindAddress(listenAddress);
27 m_AcceptChannel = std::make_shared<Channel>(m_AcceptSocket.Fd(), EventLoopThreadWrapper::GetInst());
28 m_AcceptChannel->SetReadCallback([=]() { HandleRead(); });
35 m_AcceptChannel->DisableAll();
36 m_AcceptChannel->Remove();
44 m_AcceptSocket.Listen();
45 m_AcceptChannel->EnableReading();
51 const SOCKET connectFd = m_AcceptSocket.Accept(&peerAddress);
53 if (m_ConnectionCallback)
55 m_ConnectionCallback(connectFd, peerAddress);
59 ::closesocket(connectFd);
#define SPICES_PROFILE_ZONE
void Listen()
Listen accept socket.
void HandleRead() const
On Read Event Callback.
Acceptor(const InetAddress &listenAddress, bool reusePort)
Constructor Function.
bool m_IsListening
Boolean of whether is in listening.
virtual ~Acceptor()
Destructor Function.
Wrapper of Channel and Socket, As the entrance of comm.
This class is Wrapper of current socket address.