diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-27 14:35:51 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-27 14:35:51 +0200 |
| commit | ad546ec6062e47f08352ff2c4038aba3479bfb82 (patch) | |
| tree | 1609675e80b08330d39c7c10908a1a1b7e2edd0c | |
| parent | 9078633feeb129d679c97d900807ef2d5b253b65 (diff) | |
| download | busybox-w32-ad546ec6062e47f08352ff2c4038aba3479bfb82.tar.gz busybox-w32-ad546ec6062e47f08352ff2c4038aba3479bfb82.tar.bz2 busybox-w32-ad546ec6062e47f08352ff2c4038aba3479bfb82.zip | |
Update docs/tcp.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | docs/tcp.txt | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/docs/tcp.txt b/docs/tcp.txt index 7951e1c8b..c867c6da9 100644 --- a/docs/tcp.txt +++ b/docs/tcp.txt | |||
| @@ -39,11 +39,28 @@ Solution #1: block until sending is done: | |||
| 39 | close(sock); | 39 | close(sock); |
| 40 | 40 | ||
| 41 | Solution #2: tell kernel that you are done sending. | 41 | Solution #2: tell kernel that you are done sending. |
| 42 | This makes kernel send FIN, not RST: | 42 | This makes kernel send FIN after all data is written: |
| 43 | 43 | ||
| 44 | shutdown(sock, SHUT_WR); | 44 | shutdown(sock, SHUT_WR); |
| 45 | close(sock); | 45 | close(sock); |
| 46 | 46 | ||
| 47 | However, experiments on Linux 3.9.4 show that kernel can return from | ||
| 48 | shutdown() and from close() before all data is sent, | ||
| 49 | and if peer sends any data to us after this, kernel stll responds with | ||
| 50 | RST before all our data is sent. | ||
| 51 | |||
| 52 | In practice the protocol in use often does not allow peer to send | ||
| 53 | such data to us, in which case this solution is acceptable. | ||
| 54 | |||
| 55 | If you know that peer is going to close its end after it sees our FIN | ||
| 56 | (as EOF), it might be a good idea to perform a read after shutdown(). | ||
| 57 | When read finishes with 0-sized result, we conclude that peer received all | ||
| 58 | the data, saw EOF, and closed its end. | ||
| 59 | |||
| 60 | However, this incurs small performance penalty (we run for a longer time) | ||
| 61 | and requires safeguards (nonblocking reads, timeouts etc) against | ||
| 62 | malicious peers which don't close the connection. | ||
| 63 | |||
| 47 | 64 | ||
| 48 | Defeating Nagle. | 65 | Defeating Nagle. |
| 49 | 66 | ||
