3.13.0-rc 3.12.0 (latest) 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 2.10.1 A streaming read-write RPC.
Streaming read-write RPCs (sometimes called bidirectional streaming RPCs) allow applications to send multiple "requests" and receive multiple "responses" on the same request. They are often used in services where sending one request at a time introduces too much latency. The requests

## Functions

### Cancel()

Sends a best-effort request to cancel the RPC.
The application should still wait for the current operation(s) (any pending [`Start()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1aa3043132171c86e884b2ad865dc30e49), [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c), or `Write*()` requests) to complete and use [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) to determine the status of the RPC.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `void` |   |

### Start()

Start the streaming RPC.
Applications should call one of [`Start()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1aa3043132171c86e884b2ad865dc30e49) or [`StartWithCorkedInitialMetadata()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a5126f0281eb530df8f8c3aca2eeab4b7) and wait for its result before calling [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) and/or [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431).

If [`Start()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1aa3043132171c86e884b2ad865dc30e49) completes with `false` the stream has completed with an error. The application should not call [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) or [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) in this case. On errors, the application should call [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) to determine the status of the streaming RPC.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< bool >` |   |

### StartWithCorkedInitialMetadata()

Start the streaming RPC with corked initial metadata.
Applications should call one of [`Start()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1aa3043132171c86e884b2ad865dc30e49) or [`StartWithCorkedInitialMetadata()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a5126f0281eb530df8f8c3aca2eeab4b7) and wait for its result before calling [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) and/or [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431).

If [`StartWithCorkedInitialMetadata()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a5126f0281eb530df8f8c3aca2eeab4b7) completes with `false` the stream has completed with an error. The application should not call [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) or [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) in this case. On errors, the application should call [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) to determine the status of the streaming RPC.

This method differs from [`Start()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1aa3043132171c86e884b2ad865dc30e49) by not sending the initial metadata until the first [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) call on the stream. That saves a bounce through the gRPC [CompletionQueue](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1CompletionQueue) at stream startup if the caller does not need the initial metadata in order to send the first [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< bool >` |   |

### Read()

Read one response from the streaming RPC.
<br />

> [!NOTE]
> **Note:** Only **one** [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) operation may be pending at a time. The application is responsible for waiting until any previous [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) operations have completed before calling [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) again.

Whether [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) can be called before a [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) operation is specified by each service and RPC. Most services require at least one [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) call before calling [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c). Many services may return more than one response for a single [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) request. Each service and RPC specifies how to discover if more responses will be forthcoming.

<br />

If the `optional<>` is not engaged the streaming RPC has completed. The application should wait until any other pending operations (typically any other [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) calls) complete and then call [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) to find the status of the streaming RPC.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< std::optional< Response > >` |   |

### Write(Request const \&, grpc::WriteOptions)

Write one request to the streaming RPC.
<br />

> [!NOTE]
> **Note:** Only **one** [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) operation may be pending at a time. The application is responsible for waiting until any previous [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) operations have completed before calling [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) again.

Whether [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) can be called before waiting for a matching [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) operation is specified by each service and RPC. Many services tolerate multiple [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) calls before performing or at least receiving a [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) response.

<br />

If [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) completes with `false` the streaming RPC has completed. The application should wait until any other pending operations (typically any other [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) calls) complete and then call [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) to find the status of the streaming RPC.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
|   | `Request const &` |
|   | `grpc::WriteOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< bool >` |   |

### WritesDone()

Half-closes the streaming RPC.
Sends an indication to the service that no more requests will be issued by the client.

If [`WritesDone()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a3df7a8ee22c26ea09557df1b002a6afa) completes with `false` the streaming RPC has completed. The application should wait until any other pending operations (typically any other [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) calls) complete and then call [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) to find the status of the streaming RPC.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< bool >` |   |

### Finish()

Return the final status of the streaming RPC.
Streaming RPCs may return an error because the stream is closed, independently of any whether the application has called [`WritesDone()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a3df7a8ee22c26ea09557df1b002a6afa) or signaled that the stream is closed using other mechanisms (some RPCs define specific attributes to "close" the stream).

The application must wait until all pending [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a18458f793c3547b731f5dd111de7bc0c) and [`Write()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a54050bb8b966bcebc2bf3ef396996431) operations have completed before calling [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< Status >` |   |

### virtual GetRequestMetadata() const

Return the request metadata.
Request metadata is useful for troubleshooting, but may be relatively expensive to extract. Application developers should avoid this function in the critical path.

> [!NOTE]
> **Note:** Only call this function once, and only after [`Finish()`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc#classgoogle_1_1cloud_1_1AsyncStreamingReadWriteRpc_1a350dc5a4df27303b78ee3e7c837b9cb2) completes.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `RpcMetadata` |   |