---
title: "send(_:toPeers:with:)"
framework: multipeerconnectivity
role: symbol
role_heading: Instance Method
path: "multipeerconnectivity/mcsession/send(_:topeers:with:)"
---

# send(_:toPeers:with:)

Sends a message to nearby peers.

## Declaration

```swift
func send(_ data: Data, toPeers peerIDs: [MCPeerID], with mode: MCSessionSendDataMode) throws
```

## Parameters

- `data`: An instance containing the message to send.
- `peerIDs`: An array of peer ID instances representing the peers that should receive the message.
- `mode`: The transmission mode to use (reliable or unreliable delivery).

## Discussion

Discussion This method is asynchronous (nonblocking). On the recipient device, the session instance calls its delegate instance’s session(_:didReceive:fromPeer:) method with the message after it has been fully received.

## See Also

### Sending Data and Resources

- [sendResource(at:withName:toPeer:withCompletionHandler:)](multipeerconnectivity/mcsession/sendresource(at:withname:topeer:withcompletionhandler:).md)
- [startStream(withName:toPeer:)](multipeerconnectivity/mcsession/startstream(withname:topeer:).md)
