---
title: "startStream(withName:toPeer:)"
framework: multipeerconnectivity
role: symbol
role_heading: Instance Method
path: "multipeerconnectivity/mcsession/startstream(withname:topeer:)"
---

# startStream(withName:toPeer:)

Opens a byte stream to a nearby peer.

## Declaration

```swift
func startStream(withName streamName: String, toPeer peerID: MCPeerID) throws -> OutputStream
```

## Parameters

- `streamName`: A name for the stream. This name is provided to the nearby peer.
- `peerID`: The ID of the nearby peer.

## Return Value

Return Value In Swift, an output stream instance. In Objective-C, an output stream object upon success or nil if a stream could not be established.

## Discussion

Discussion This method is nonblocking. For more information about performing networking with input and output streams, read Networking Programming Topics.

## See Also

### Sending Data and Resources

- [send(_:toPeers:with:)](multipeerconnectivity/mcsession/send(_:topeers:with:).md)
- [sendResource(at:withName:toPeer:withCompletionHandler:)](multipeerconnectivity/mcsession/sendresource(at:withname:topeer:withcompletionhandler:).md)
