<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Stream/getStreamsTo(_:port:inputStream:outputStream:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSStream(cm)getStreamsToHost:port:inputStream:outputStream:"
  },
  "title" : "getStreamsTo(_:port:inputStream:outputStream:)"
}
-->

# getStreamsTo(_:port:inputStream:outputStream:)

Creates and returns by reference an `NSInputStream` object and `NSOutputStream` object for a socket connection with a given host on a given port.

```
class func getStreamsTo(_ host: Host, port: Int, inputStream: AutoreleasingUnsafeMutablePointer<InputStream?>?, outputStream: AutoreleasingUnsafeMutablePointer<OutputStream?>?)
```

## Parameters

`host`

The host to which to connect.

`port`

The port to connect to on `host`.

`inputStream`

Upon return, contains the input stream. If `nil` is passed, the stream object is not created.

`outputStream`

Upon return, contains the output stream. If `nil` is passed, the stream object is not created.

## Discussion

If neither `port` nor `host` is properly specified, no socket connection is made.

## See Also

  [Stream Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Streams/Streams.html#//apple_ref/doc/uid/10000188i)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)