MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

connectd/websocketd.c:320–349  ·  view source on GitHub ↗

stdin goes to the client, stdout goes to lightningd */

Source from the content-addressed store, hash-verified

318
319/* stdin goes to the client, stdout goes to lightningd */
320int main(int argc, char *argv[])
321{
322 struct pollfd pfds[2];
323
324 common_setup(argv[0]);
325
326 if (argc != 1)
327 errx(1, "Usage: %s", argv[0]);
328
329 /* Do HTTP-style negotiation to get into websocket frames. */
330 io_fd_block(STDIN_FILENO, true);
331 http_upgrade(STDIN_FILENO);
332
333 pfds[0].fd = STDIN_FILENO;
334 pfds[0].events = POLLIN;
335 pfds[1].fd = STDOUT_FILENO;
336 pfds[1].events = POLLIN;
337
338 for (;;) {
339 poll(pfds, 2, -1);
340
341 if (pfds[1].revents & POLLIN)
342 lightningd_to_websocket(STDOUT_FILENO, STDIN_FILENO);
343 if (pfds[0].revents & POLLIN)
344 websocket_to_lightningd(STDIN_FILENO, STDOUT_FILENO);
345 }
346
347 common_shutdown();
348 exit(0);
349}

Callers

nothing calls this directly

Calls 7

common_setupFunction · 0.85
errxFunction · 0.85
io_fd_blockFunction · 0.85
http_upgradeFunction · 0.85
lightningd_to_websocketFunction · 0.85
websocket_to_lightningdFunction · 0.85
common_shutdownFunction · 0.85

Tested by

no test coverage detected