MCPcopy Create free account
hub / github.com/dermesser/libsocket / add_fd

Method add_fd

headers/select.hpp:146–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144 */
145template <typename SocketT>
146void 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.

Callers

nothing calls this directly

Calls 1

getfdMethod · 0.80

Tested by

no test coverage detected