Instance Method
writeData(_:)
Send a raw byte payload, looping until every byte is written.
func writeData(_ data: Data) throws
Parameters
-
data
-
The bytes to write verbatim.
Discussion
Low-level counterpart to writeLine(_:). Called when the caller needs to ship a pre-assembled payload (multi-line commands, binary-safe extensions). Loops over send(2) until the full data has been drained, handling short writes transparently.
Throws
TorError.ioError(_:) if the FD is closed or any send(2) returns -1.
Important
Partial writes are not reported to the caller — swift-tor retries transparently. If send(2) fails mid- payload the caller must treat the socket as compromised and abandon it; the Tor peer has consumed an unknown prefix of the intended command.