---
title: "CFStreamCreatePairWithSocketToCFHost(_:_:_:_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfstreamcreatepairwithsockettocfhost(_:_:_:_:_:)"
---

# CFStreamCreatePairWithSocketToCFHost(_:_:_:_:_:)

Creates readable and writable streams connected to a given CFHost object.

## Declaration

```swift
func CFStreamCreatePairWithSocketToCFHost(_ alloc: CFAllocator?, _ host: CFHost, _ port: Int32, _ readStream: UnsafeMutablePointer<Unmanaged<CFReadStream>?>?, _ writeStream: UnsafeMutablePointer<Unmanaged<CFWriteStream>?>?)
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the CFReadStream and CFWriteStream objects. Pass NULL or kCFAllocatorDefault to use the current default allocator.
- `host`: A CFHost object to which the streams are connected. If unresolved, the host will be resolved prior to connecting.
- `port`: The TCP port number to which the socket streams should connect.
- `readStream`: Upon return, contains a CFReadStream object connected to the host host on port port, or NULL if there is a failure during creation. If you pass NULL, the function will not create a readable stream. Ownership follows the https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029.
- `writeStream`: Upon return, contains a CFWriteStream object connected to the host host on port port, or NULL if there is a failure during creation. If you pass NULL, the function will not create a writable stream. Ownership follows the https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029.

## Discussion

Discussion The streams do not create a socket or connect to the specified host until you open one of the streams. Most properties are shared by both streams. Setting a shared property for one stream automatically sets the property for the other.

## See Also

### Streams

- [CFReadStreamCreateForHTTPRequest(_:_:)](cfnetwork/cfreadstreamcreateforhttprequest(_:_:).md)
- [CFReadStreamCreateForStreamedHTTPRequest(_:_:_:)](cfnetwork/cfreadstreamcreateforstreamedhttprequest(_:_:_:).md)
- [kCFStreamPropertyHTTPAttemptPersistentConnection](cfnetwork/kcfstreampropertyhttpattemptpersistentconnection.md)
- [kCFStreamPropertyHTTPFinalRequest](cfnetwork/kcfstreampropertyhttpfinalrequest.md)
- [kCFStreamPropertyHTTPFinalURL](cfnetwork/kcfstreampropertyhttpfinalurl.md)
- [kCFStreamPropertyHTTPProxy](cfnetwork/kcfstreampropertyhttpproxy.md)
- [kCFStreamPropertyHTTPProxyHost](cfnetwork/kcfstreampropertyhttpproxyhost.md)
- [kCFStreamPropertyHTTPProxyPort](cfnetwork/kcfstreampropertyhttpproxyport.md)
- [kCFStreamPropertyHTTPRequestBytesWrittenCount](cfnetwork/kcfstreampropertyhttprequestbyteswrittencount.md)
- [kCFStreamPropertyHTTPResponseHeader](cfnetwork/kcfstreampropertyhttpresponseheader.md)
- [kCFStreamPropertyHTTPSProxyHost](cfnetwork/kcfstreampropertyhttpsproxyhost.md)
- [kCFStreamPropertyHTTPSProxyPort](cfnetwork/kcfstreampropertyhttpsproxyport.md)
- [kCFStreamPropertyHTTPShouldAutoredirect](cfnetwork/kcfstreampropertyhttpshouldautoredirect.md)
- [CFWriteStreamCreateWithFTPURL(_:_:)](cfnetwork/cfwritestreamcreatewithftpurl(_:_:).md)
- [CFReadStreamCreateWithFTPURL(_:_:)](cfnetwork/cfreadstreamcreatewithftpurl(_:_:).md)
