Commit 28ca40b
committed
Providing a more fair servicing of multiple tcp clients.
I modified `EthernetServer::available()` such that it will not always pick the
socket with the lowest number that has data available. Instead when the method
returned the client at socket i, it will check socket (i+1) % MAX_SOCK_NUM first
when then method is called the next time.
The problem with the previous implementation is that if there is a client
connected to a socket with a low number (e.g. the first one with number 0) and the
peer constantly sends data. In that case `EthernetServer::available()` always
returns that client. The clients, which are connected to a socket with a higher
number (e.g. 1, 2, or 3), can only be returned when the ones with lower numbers
have no data available.
This problem is fixed with this commit.
This commit also implements the changes suggested by @matthijskooijman.1 parent 19a9e4d commit 28ca40b
2 files changed
+9
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
61 | | - | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
0 commit comments