<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Event",
  "identifier" : "/documentation/Event/Socket/read(maxBytes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Event"
    ],
    "preciseIdentifier" : "s:5Event6SocketC4read8maxBytes10Foundation4DataVSi_tYaKF"
  },
  "title" : "read(maxBytes:)"
}
-->

# 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.

## 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: ``doc://Event/documentation/Event/SocketError/connectionClosed`` on orderly peer shutdown
> (`read(2)` returns 0), or ``doc://Event/documentation/Event/SocketError/readFailed(_:)`` with the errno
> payload on transport failure.