-
Hi,
This code works but it will never disconnect from sever even if client close its connection .
I set timeout to 120 seconds its OK but usually my clients finish their job under 10 seconds so lot of connection remain ESTABLISHED on server host and our old backhand has some problems with lot of connections I could reduce the timeout but in some slow case that would be a problem.
This works very well but I do not understand it, What is going on beneath it
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In general, a TCP stream has two directions of communication, and each direction is closed independently. When you call You usually don't close your stream in the read direction — that's the job of the other client, since that's their write direction. The caller from the docs is whoever called |
Beta Was this translation helpful? Give feedback.
In general, a TCP stream has two directions of communication, and each direction is closed independently. When you call
shutdown
, that closes your write direction, and the other end'sread
call will return with a read of length zero, which indicates that the stream is permanently closed in that direction. Thetokio::io::copy
method will keep running until it gets a read of length zero, at which point it will make sure to finish writing anything it still hasn't written, then return.You usually don't close your stream in the read direction — that's the job of the other client, since that's their write direction.
The caller from the docs is whoever called
shutdown
.