The Socks5()
function which does the SOCKS5 handshake with the SOCKS5 proxy sends bytes to the socket without retrying partial writes.
send(2)
may write only part of the provided data and return. In this case the caller is responsible for retrying the operation with the remaining data. Change Socks5()
to do that. There is already a method Sock::SendComplete()
which does exactly that, so use it in Socks5()
.
A minor complication for this PR is that Sock::SendComplete()
takes std::string
argument whereas Socks5()
has std::vector<uint8_t>
. Thus the necessity for the first commit. It is possible to do also in other ways - convert the data in Socks5()
to std::string
or have just one Sock::SendComplete()
that takes void*
and change the callers to pass str.data(), str.size()
or vec.data(), vec.size()
.
This came up while testing #27375.