wip put poll version inside luke version
This commit is contained in:
16
README.md
16
README.md
@@ -80,13 +80,16 @@
|
||||
## code architecture
|
||||
|
||||
|
||||
```
|
||||
```
|
||||
functions action in this scenario :
|
||||
______
|
||||
sd = SOCKET() : create a listening socket descriptor
|
||||
__________
|
||||
SETSOCKOPT(sd) : allow socket descriptor to be reuseable
|
||||
_____
|
||||
IOCTL(sd) : set listening socket and all incoming socket to be non-blocking
|
||||
_____
|
||||
FCNTL(sd) : set listening socket and all incoming socket to be non-blocking
|
||||
____
|
||||
BIND(port) : associate listening socket to a port
|
||||
______
|
||||
@@ -115,7 +118,7 @@
|
||||
compare architectures :
|
||||
|
||||
```
|
||||
POLL SELECT
|
||||
POLL SELECT
|
||||
______ ______ ______
|
||||
lstn_sd = SOCKET() | lstn_sd = SOCKET() | lstn_sd = SOCKET()
|
||||
| __________ | __________
|
||||
@@ -138,6 +141,7 @@ compare architectures :
|
||||
. | . loop through fds[] | . loop i++ < max_fd
|
||||
. | . . | . .
|
||||
. | . . POLLIN && lstn_sd ? | . . FD_ISSET(i) & lstn_fd ?
|
||||
. | . . loop | . . loop
|
||||
. ______ | . . . ______ | . . . ______
|
||||
. ACCEPT() | . . . new_sd = ACCEPT() | . . . new_sd = ACCEPT()
|
||||
. | . . . | . . .
|
||||
@@ -145,7 +149,8 @@ compare architectures :
|
||||
. | . . | . . .
|
||||
. | . . | . . . max_sd = new_sd
|
||||
. | . . | . .
|
||||
. | . . POLLIN ? | . . FD_ISSET ?
|
||||
. | . . or POLLIN ? | . . or FD_ISSET ?
|
||||
. | . . loop | . . loop
|
||||
. ____ | . . . ____ | . . . ____
|
||||
. RECV() | . . . RECV() | . . . RECV()
|
||||
. ____ | . . . ____ | . . . ____
|
||||
@@ -156,5 +161,10 @@ compare architectures :
|
||||
. CLOSE(fds[]) | . CLOSE(fds[]) | . CLOSE(fds[])
|
||||
|
||||
|
||||
first, create the socket, add some options, bind it, and listen to it.
|
||||
then, do a loop starting with POLL or SELECT
|
||||
if it's incomming connexions, accept and add them all to the list
|
||||
if it's accepted connexions, read their datas and write new datas
|
||||
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user