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

Function main

connectd/websocketd.c:316–345  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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