---
title: "enqueueIORequest(with:completionHandler:)"
framework: iousbhost
role: symbol
role_heading: Instance Method
path: "iousbhost/iousbhoststream/enqueueiorequest(with:completionhandler:)"
---

# enqueueIORequest(with:completionHandler:)

Enqueues an input/output request on the stream.

## Declaration

```swift
func enqueueIORequest(with data: NSMutableData?, completionHandler: (@Sendable (IOReturn, Int) -> Void)? = nil) throws
```

```swift
func enqueueIORequest(with data: NSMutableData?) async throws -> (IOReturn, Int)
```

## Parameters

- `data`: An doc://com.apple.documentation/documentation/Foundation/NSMutableData object defining the memory to use for the transfer.
- `completionHandler`: An doc://com.apple.iousbhost/documentation/IOUSBHost/IOUSBHostCompletionHandler that runs when the request completes. The completionHandler doesn’t run if the method returns an error.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func enqueueIORequest(with data: NSMutableData?) async throws -> (IOReturn, Int) For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. This method sends an asynchronous request on the stream. note: Completion timeouts aren’t applicable to streams.

## See Also

### Sending I/O

- [IOUSBHostCompletionHandler](iousbhost/iousbhostcompletionhandler.md)
- [abort(with:)](iousbhost/iousbhoststream/abort(with:).md)
- [abort()](iousbhost/iousbhoststream/abort().md)
