| 118 | } |
| 119 | |
| 120 | bool 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 | |
| 146 | bool TcpSocket::acceptConnection(SocketClient &client, bool showLogInfo) { |
| 147 | // check if we have a client? |
nothing calls this directly
no test coverage detected