| 53 | // ============================================================================ |
| 54 | |
| 55 | void TcpSocket::initialize(const std::string &ipAddr, int port, bool nonblock) { |
| 56 | for (std::size_t i = 0; i < _MAX_CLIENTS; ++i) { |
| 57 | _client[i].setProtocol(_protocolString); |
| 58 | } |
| 59 | if (initServerSocket(ipAddr, port, _MAX_CLIENTS, nonblock)) { |
| 60 | _pfd[0].fd = _server.getFD(); |
| 61 | _pfd[0].events = POLLIN | POLLHUP | POLLRDNORM | POLLERR; |
| 62 | _pfd[0].revents = 0; |
| 63 | |
| 64 | for (std::size_t i = 1; i < _MAX_POLL; ++i) { |
| 65 | _pfd[i].fd = -1; |
| 66 | _pfd[i].events = POLLIN | POLLHUP | POLLRDNORM | POLLERR; |
| 67 | _pfd[i].revents = 0; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | int TcpSocket::poll(int timeout) { |
| 73 | if (::poll(_pfd, _MAX_POLL, timeout) > 0) { |
no test coverage detected