- success — all bytes accepted (sent to OS or queued)
- SendErrorReason.PRESSURE — zero bytes queued, budget exceeded
- SendErrorReason.CLOSED — connection not in CONNECTED state
- SendErrorReason.ERROR — system error;
errnocarries the code
UnixConnection.send
SendStatus send(scope const(ubyte)[] data) @trustedSend bytes over the connection.
Data is copied into an internal send queue. The caller may reuse or free the buffer immediately after this method returns.
Backpressure: returns a SendError with reason SendErrorReason.PRESSURE when the internal queue would exceed the configured highWaterMark or the global EventLoop send queue limit. The caller must wait for onWritable before retrying.
Parameters
data | Bytes to send. |
Returns
SendStatus send(scope const(ubyte)[] data, scope const(Handle)[] descriptors) @trustedSend bytes and pass open descriptors over the connection (SCM_RIGHTS).
On success the bytes are Copied into the internal send queue (as with send(data)) and each descriptor is duplicated into a queue-Owned close-on-exec handle; the caller retains ownership of the originals and may close or reuse them immediately after this method returns. A rejected call closes the tentative duplicates and enqueues nothing.
Descriptors form an ordered stream independent of the byte stream: the peer collects them FIFO through ReceivedDescriptors, with no association to a byte offset. Queued descriptors are attached to the first positive sendmsg of their output chunk and are never sent twice; abort, close or cancellation releases them exactly once.
Parameters
data | Bytes to send; must not be empty when descriptors are given. |
descriptors | Open descriptors to pass; at most UNIX_MAX_DESCRIPTORS_PER_SEND per call. |
Returns
- success — all bytes accepted and all descriptors duplicated
- SendErrorReason.PRESSURE — zero bytes queued; byte
budget, the aggregate
maxQueuedDescriptorsbudget or the loop send-queue limit exceeded - SendErrorReason.CLOSED — connection not in CONNECTED
state
- SendErrorReason.INVALID_ARGUMENT — empty
data, adescriptor count above the per-send limit, or an invalid descriptor
- SendErrorReason.ERROR — system error;
errnocarries the code (e.g. descriptor duplication failure)