---
title: "init(protocolFamily:socketType:protocol:socket:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/socketport/init(protocolfamily:sockettype:protocol:socket:)"
---

# init(protocolFamily:socketType:protocol:socket:)

Initializes the receiver with a previously created local socket.

## Declaration

```swift
init?(protocolFamily family: Int32, socketType type: Int32, protocol: Int32, socket sock: SocketNativeHandle)
```

## Parameters

- `family`: The protocol family for the provided socket. Possible values are defined in <sys/socket.h>, such as AF_LOCAL, AF_INET, and AF_INET6.
- `type`: The type of the provided socket.
- `protocol`: The specific protocol the provided socket uses.
- `sock`: The previously created socket.

## Return Value

Return Value A local socket port initialized with the provided socket.

## 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(remoteWithTCPPort:host:)](foundation/socketport/init(remotewithtcpport:host:).md)
- [init(remoteWithProtocolFamily:socketType:protocol:address:)](foundation/socketport/init(remotewithprotocolfamily:sockettype:protocol:address:).md)
