---
title: "getStreamsToHost(withName:port:inputStream:outputStream:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/stream/getstreamstohost(withname:port:inputstream:outputstream:)"
---

# getStreamsToHost(withName: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.

## Declaration

```swift
class func getStreamsToHost(withName hostname: String, port: Int, inputStream: AutoreleasingUnsafeMutablePointer<InputStream?>?, outputStream: AutoreleasingUnsafeMutablePointer<OutputStream?>?)
```

## Parameters

- `hostname`: 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.
