send

abstract suspend fun send(connectionId: NwConnectionId, bytes: ByteArray)

Send raw bytes over connectionId. Framing is the caller's responsibility.

An immediately-known failure MUST throw NwSendFailedException — an implementation that knows, before handing anything to the transport, that connectionId is unknown or already closed reports that by throwing, not by returning. NwSeam treats a throw as its cue to evict that connection. This used to read "MAY throw", and RealNwApi took the option: it logged the dead id at debug and returned normally, which made its half of NwSeam's send-failure eviction dead code and turned a frame written onto a destroyed connection into a silent discard with no warn, no error and no retry (#2455 — the loss that made the #2425 wedge undiagnosable). "MAY" is not a contract a caller can build on; the eviction is, so this direction is now required.

A non-throwing send still means "handed off", NOT "delivered". A real transport reports most send failures asynchronously — the link breaks after the call returns — and this method does not wait for the transport's completion, so it cannot and must not be read as an acknowledgement. Those failures surface via connectionClosed (the fast reason-carrying path), backstopped by the drop-tolerant connectionStates Closed STATE; together they remain the authoritative teardown signal, and an implementation that learns of an asynchronous send failure routes it there rather than inventing a late throw nobody is waiting to catch.

Throws

if connectionId is unknown to this binding or already closed.