SpiecsEngine
 
Loading...
Searching...
No Matches

◆ TcpServer() [1/2]

Spices::Net::TcpServer::TcpServer ( const InetAddress & listenAddress,
Option option = Option::NoReusePort )

Constructor Function.

Parameters
[in]listenAddressServer listen address.
[in]optionIs reuse port.

Definition at line 16 of file TcpServer.cpp.

21 {
23
24 m_IpPort = listenAddress.ToIPPort();
25
26 m_Acceptor = std::make_unique<Acceptor>(listenAddress, option == Option::ReusePort);
27 m_Acceptor->SetConnectionCallback(std::bind(&TcpServer::NewConnection, this, std::placeholders::_1, std::placeholders::_2));
28
29 m_ThreadPool = std::make_shared<EventLoopThreadPool>(listenAddress);
31 }
#define SPICES_PROFILE_ZONE
std::shared_ptr< EventLoopThreadPool > m_ThreadPool
ThreadPool.
Definition TcpServer.h:145
void NewConnection(SOCKET socketFd, const InetAddress &peerAddress)
Handle New Connection to Acceptor.
Definition TcpServer.cpp:57
std::unique_ptr< Acceptor > m_Acceptor
Acceptor.
Definition TcpServer.h:140
std::string m_IpPort
TcpServer Ip and Port.
Definition TcpServer.h:135
int m_NextConnectedId
Next Connection id.
Definition TcpServer.h:170

References m_IpPort, m_NextConnectedId, and Spices::Net::InetAddress::ToIPPort().