<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/SocketPort/init(protocolFamily:socketType:protocol:socket:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSocketPort(im)initWithProtocolFamily:socketType:protocol:socket:"
  },
  "title" : "init(protocolFamily:socketType:protocol:socket:)"
}
-->

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

Initializes the receiver with a previously created local socket.

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

A local socket port initialized with the provided socket.

## Discussion

---

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)