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

# enqueueIORequest(with:completionTimeout:completionHandler:)

Enqueues an input/output request on the pipe.

## Declaration

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

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

## Parameters

- `data`: An doc://com.apple.documentation/documentation/Foundation/NSMutableData object defining the memory to use for the transfer. Use doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0 to send a zero-length packet.
- `completionTimeout`: A doc://com.apple.documentation/documentation/Foundation/TimeInterval value representing the timeout of the request. If 0, the request never times out. Use doc://com.apple.iousbhost/documentation/IOUSBHost/IOUSBHostDefaultControlCompletionTimeout unless there’s a need for a specific timeout.
- `completionHandler`: An doc://com.apple.iousbhost/documentation/IOUSBHost/IOUSBHostCompletionHandler that runs when the request completes, or times out after the call returns successfully. If the method returns with an error, the completion handler doesn’t run.

## 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?, completionTimeout: TimeInterval) async throws -> (IOReturn, Int) For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. Use this method to issue an asynchronous input/output request on a bulk or interrupt pipe.

## See Also

### Sending Bulk and Interrupt I/O

- [IOUSBHostCompletionHandler](iousbhost/iousbhostcompletionhandler.md)
- [IOUSBHostDefaultControlCompletionTimeout](iousbhost/iousbhostdefaultcontrolcompletiontimeout.md)
- [clearStall()](iousbhost/iousbhostpipe/clearstall().md)
