<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NetService/Options/listenForConnections",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@E@NSNetServiceOptions@NSNetServiceListenForConnections"
  },
  "title" : "listenForConnections"
}
-->

# listenForConnections

```
static var listenForConnections: NetService.Options { get }
```

## Discussion

Specifies that a TCP listener should be started for both IPv4 and IPv6 on the port specified by this service. If the listening port can’t be opened, the service calls its delegate’s [`netService(_:didNotPublish:)`](/documentation/Foundation/NetServiceDelegate/netService(_:didNotPublish:)) method to report the error.

The listener supports only TCP connections. If the service’s type does not end with `_tcp`, publication fails with [`NetService.ErrorCode.badArgumentError`](/documentation/Foundation/NetService/ErrorCode-swift.enum/badArgumentError).

Whenever a client connects to the listening socket, the service calls its delegate’s [`netService(_:didAcceptConnectionWith:outputStream:)`](/documentation/Foundation/NetServiceDelegate/netService(_:didAcceptConnectionWith:outputStream:)) method with a pair of `NSStream` objects.

---

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)