wip put poll version inside luke version

This commit is contained in:
hugogogo
2022-07-20 17:11:24 +02:00
parent fecf5411bc
commit 708da8bb61
6 changed files with 523 additions and 334 deletions

View File

@@ -12,7 +12,7 @@ int main(void)
// https://security.stackexchange.com/questions/169213/how-to-chose-a-port-to-run-an-application-on-localhost
serv.bind(4040);
serv.listen(512); // 512 max connections arbitrary
serv.listen(20);
serv.start();
}
catch (std::exception& e)
@@ -22,45 +22,3 @@ int main(void)
return (0);
}
/*
______
listen_fd = SOCKET() : create a listening socket
__________
SETSOCKOPT() : Allow socket descriptor to be reuseable
_____
IOCTL() : set listen_fd and all incoming socket to be non-blocking
____
BIND(port) : associate listen_fd to a port
______
LISTEN(nb_queue) : queue the incoming connections to listen_fd, up to a chosen number
fds[1] = listen_fd
loop
. ____
. POLL(fds[]) :
.
. loop through fds[]
. .
. . POLLIN && listen_fd ? : readable socket and this is the listening one
. . . ______
. . . new_fd = ACCEPT() : extract first connection request in queue of listen_fd
. . . and creates a new socket that is connected
. . .
. . . fds[] += new_fd
. .
. . POLLIN ? : readable socket and this is an active one
. . . ____
. . . RECV() : read data in socket created by accept()
. . . ____
. . . SEND() : write data in socket created by accept()
loop through fds[] :
. _____
. CLOSE(fds[])
*/