MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / main_loop

Function main_loop

test/sockets/test_tcp_refused.c:40–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void main_loop(void) {
41 fd_set fdw;
42 struct timeval tv = {0};
43 FD_ZERO(&fdw);
44 FD_SET(fd, &fdw);
45 select(64, NULL, &fdw, NULL, &tv);
46
47 if (FD_ISSET(fd, &fdw)) {
48 int err = 0;
49 socklen_t l = sizeof(err);
50 getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &l);
51 if (err == 0) return; // not resolved yet
52 printf("connect resolved with errno %d (%s)\n", err, strerror(err));
53 assert(err == ECONNREFUSED && "expected ECONNREFUSED");
54 test_success();
55 }
56}
57
58int main(void) {
59 fd = socket(AF_INET, SOCK_STREAM, 0);

Callers 1

mainFunction · 0.70

Calls 6

selectFunction · 0.85
printfFunction · 0.85
strerrorFunction · 0.85
test_successFunction · 0.70
getsockoptFunction · 0.50
assertFunction · 0.50

Tested by

no test coverage detected