MCPcopy Create free account
hub / github.com/Barracuda09/SATPI / initServerSocket

Method initServerSocket

src/socket/TcpSocket.cpp:120–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120bool TcpSocket::initServerSocket(
121 const std::string &ipAddr,
122 int port,
123 int maxClients,
124 bool nonblock) {
125 // fill in the socket structure with host information
126 _server.setupSocketStructure(ipAddr, port);
127
128 if (!_server.setupSocketHandle(SOCK_STREAM | ((nonblock) ? SOCK_NONBLOCK : 0), 0)) {
129 SI_LOG_ERROR("TCP Server handle failed");
130 return false;
131 }
132
133 _server.setSocketTimeoutInSec(2);
134
135 if (!_server.bind()) {
136 SI_LOG_ERROR("TCP Bind failed");
137 return false;
138 }
139 if (!_server.listen(maxClients)) {
140 SI_LOG_ERROR("TCP Listen failed");
141 return false;
142 }
143 return true;
144}
145
146bool TcpSocket::acceptConnection(SocketClient &client, bool showLogInfo) {
147 // check if we have a client?

Callers

nothing calls this directly

Calls 5

setupSocketStructureMethod · 0.80
setupSocketHandleMethod · 0.80
setSocketTimeoutInSecMethod · 0.80
bindMethod · 0.80
listenMethod · 0.80

Tested by

no test coverage detected