MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / evhttp_bind_accept_socket

Function evhttp_bind_accept_socket

src/commons/support/events.cpp:195–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195struct 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}

Callers 1

HTTPBindAddressesFunction · 0.85

Calls 1

bind_socketFunction · 0.85

Tested by

no test coverage detected