---
title: "connect(endpoint:)"
framework: foveatedstreaming
role: symbol
role_heading: Instance Method
path: "foveatedstreaming/foveatedstreamingsession/connect(endpoint:)"
---

# connect(endpoint:)

Establishes a streaming connection at the provided endpoint.

## Declaration

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

## Parameters

- `endpoint`: The streaming endpoint to connect to.

## Discussion

Discussion note: A FoveatedStreamingSession.DisconnectReason error if a disconnection occurs.  Or, a CancellationError if the task is cancelled. You can establish a streaming connection in a variety of ways: // 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().
