| 144 | */ |
| 145 | template <typename SocketT> |
| 146 | void selectset<SocketT>::add_fd(const SocketT& sock, int method) { |
| 147 | int fd = sock.getfd(); |
| 148 | |
| 149 | if (method == LIBSOCKET_READ) { |
| 150 | poll::pollfd fdinfo{fd, POLLIN, 0}; |
| 151 | pollfd_set.push_back(fdinfo); |
| 152 | fdsockmap[fd] = const_cast<SocketT*>(&sock); |
| 153 | set_up = true; |
| 154 | |
| 155 | } else if (method == LIBSOCKET_WRITE) { |
| 156 | poll::pollfd fdinfo{fd, POLLOUT, 0}; |
| 157 | pollfd_set.push_back(fdinfo); |
| 158 | fdsockmap[fd] = const_cast<SocketT*>(&sock); |
| 159 | set_up = true; |
| 160 | } else if (method == |
| 161 | (LIBSOCKET_READ | LIBSOCKET_WRITE)) { // don't put the fd in our |
| 162 | // data structures twice. |
| 163 | poll::pollfd fdinfo{fd, (POLLIN | POLLOUT), 0}; |
| 164 | pollfd_set.push_back(fdinfo); |
| 165 | fdsockmap[fd] = const_cast<SocketT*>(&sock); |
| 166 | set_up = true; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * @brief Waits for a possibility to read or write data to emerge. |