Instance Method
read(maxBytes:)
Reads up to maxBytes bytes from the socket, awaiting readiness.
func read(maxBytes: Int = 4096) async throws -> Data
Parameters
-
maxBytes
-
Requested maximum byte count (ignored today; see note).
Return Value
The data read from the socket.
Mentioned In
Discussion
Registers an EV_READ event and drives the loop until the descriptor is readable, then issues a single read(2) syscall.
Important
The maxBytes parameter is currently advisory — the internal buffer is fixed at 4096 bytes regardless. This is a known limitation; the parameter is preserved for ABI stability so a future release can honor it without breaking callers.
Throws
SocketError.connectionClosed on orderly peer shutdown (read(2) returns 0), or SocketError.readFailed(_:) with the errno payload on transport failure.