---
title: "sendPing(pongReceiveHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlsessionwebsockettask/sendping(pongreceivehandler:)"
---

# sendPing(pongReceiveHandler:)

Sends a ping frame from the client side, with a closure to receive the pong from the server endpoint.

## Declaration

```swift
func sendPing(pongReceiveHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

- `pongReceiveHandler`: A closure called by the task when it receives the pong from the server. The block/closure receives an doc://com.apple.foundation/documentation/Foundation/NSError that indicates a lost connection or other problem, or nil if no error occurred.

## Discussion

Discussion When sending multiple pings, the task always calls pongReceiveHandler in the order it sent the pings.
