Use write_all and flush for socks replies

The current socks proxy code is error-prone when it writes replies. It does something like this:

                            let reply =
                                request.reply(tor_socksproto::SocksStatus::GENERAL_FAILURE, None);
                            socks_w
                                .write(&reply[..])
                                .await
                                .context("Couldn't write SOCKS reply")?;

But there are two issues: the write function doesn't actually have to write all of the data it's given: instead, it is allowed to write only some of the data. So we should call write_all instead.

Also, even after write_all is called, we don't have a guarantee that the data will really be sent on the network. To get that, we need to call flush() or close(). (We should call close() on errors and flush() on success reporting.)

This logic is complicated enough that we should probably have a new function in proxy.rs that does it all for us, to avoid duplicated code.