| 193 | } |
| 194 | |
| 195 | struct evhttp_bound_socket* evhttp_bind_accept_socket(struct evhttp* http, const char* address, |
| 196 | ev_uint16_t port) { |
| 197 | evutil_socket_t fd; |
| 198 | struct evhttp_bound_socket* bound; |
| 199 | int serrno; |
| 200 | |
| 201 | if ((fd = bind_socket(address, port, 1 /*reuse*/)) == -1) return (NULL); |
| 202 | |
| 203 | if (listen(fd, 128) == -1) { |
| 204 | serrno = EVUTIL_SOCKET_ERROR(); |
| 205 | LogPrint(BCLog::ERROR, "evhttp_bind_accept_socket listen failed! err: \n", |
| 206 | evutil_socket_error_to_string(serrno)); |
| 207 | evutil_closesocket(fd); |
| 208 | EVUTIL_SET_SOCKET_ERROR(serrno); |
| 209 | return (NULL); |
| 210 | } |
| 211 | |
| 212 | bound = evhttp_accept_socket_with_handle(http, fd); |
| 213 | |
| 214 | if (bound != NULL) { |
| 215 | LogPrint(BCLog::LIBEVENT, |
| 216 | "evhttp_bind_accept_socket Bound to port %d - Awaiting connections ... \n", port); |
| 217 | return (bound); |
| 218 | } |
| 219 | |
| 220 | return (NULL); |
| 221 | } |
no test coverage detected