---
title: "getStreamsTo(_:port:inputStream:outputStream:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/stream/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.

## Declaration

```swift
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

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

## See Also

### Related Documentation

- [Stream Programming Guide](apple-archive/documentation/Cocoa/Conceptual/Streams.md)
