<!--
{
  "availability" : [
    "visionOS: 26.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoveatedStreaming",
  "identifier" : "/documentation/FoveatedStreaming/FoveatedStreamingSession/connect(endpoint:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foveated Streaming",
      "FoveatedStreaming"
    ],
    "preciseIdentifier" : "s:17FoveatedStreaming0aB7SessionC7connect8endpointyAC8EndpointV_tYaKF"
  },
  "title" : "connect(endpoint:)"
}
-->

# connect(endpoint:)

Establishes a streaming connection at the provided endpoint.

```
@MainActor final func connect(endpoint: FoveatedStreamingSession.Endpoint = .systemDiscovered) async throws
```

## Parameters

`endpoint`

The streaming endpoint to connect to.

## Discussion> Throws: A ``doc://com.apple.FoveatedStreaming/documentation/FoveatedStreaming/FoveatedStreamingSession/DisconnectReason`` error if a disconnection occurs.  Or, a <doc://com.apple.documentation/documentation/Swift/CancellationError> if the task is cancelled.

You can establish a streaming connection in a variety of ways:

```swift
// Connect by discovering nearby endpoints.
try await session.connect(endpoint: .systemDiscovered)

// Connect directly with IP address and port number.
try await session.connect(endpoint: .local(ipAddress: "125.125.125.125", port: 55000))

// Connect to a remote cloud endpoint by specifying a server name
// which corresponds to an entry in the `ApprovedStreamingEndpoints` dictionary in Info.plist.
try await session.connect(endpoint: .remote(serverName: "My Remote Server", signalingHeaders: ["test-header": "my-test"])
```

You can stop establishing a connection by cancelling the task or calling [`disconnect()`](/documentation/FoveatedStreaming/FoveatedStreamingSession/disconnect()).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)