---
title: "init(remoteWithTCPPort:host:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/socketport/init(remotewithtcpport:host:)"
---

# init(remoteWithTCPPort:host:)

Initializes the receiver as a TCP/IP socket of type SOCK_STREAM that can connect to a remote host on a specified port.

## Declaration

```swift
convenience init?(remoteWithTCPPort port: UInt16, host hostName: String?)
```

## Parameters

- `port`: The port to connect to.
- `hostName`: The host name to connect to. hostName may be either a host name or an IPv4-style address.

## Return Value

Return Value A TCP/IP socket port of type SOCK_STREAM that can connect to the remote host hostName on port port.

## Discussion

Discussion A connection is not opened to the remote host until data is sent.

## See Also

### Creating Instances

- [init()](foundation/socketport/init().md)
- [init(tcpPort:)](foundation/socketport/init(tcpport:)-6hgbo.md)
- [init(protocolFamily:socketType:protocol:address:)](foundation/socketport/init(protocolfamily:sockettype:protocol:address:).md)
- [init(protocolFamily:socketType:protocol:socket:)](foundation/socketport/init(protocolfamily:sockettype:protocol:socket:).md)
- [init(remoteWithProtocolFamily:socketType:protocol:address:)](foundation/socketport/init(remotewithprotocolfamily:sockettype:protocol:address:).md)
