<!--
{
  "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/NetServiceDelegate/netService(_:didAcceptConnectionWith:outputStream:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSNetServiceDelegate(im)netService:didAcceptConnectionWithInputStream:outputStream:"
  },
  "title" : "netService(_:didAcceptConnectionWith:outputStream:)"
}
-->

# netService(_:didAcceptConnectionWith:outputStream:)

Called when a client connects to a service managed by Bonjour.

```
optional func netService(_ sender: NetService, didAcceptConnectionWith inputStream: InputStream, outputStream: OutputStream)
```

## Parameters

`sender`

The net service object that the client connected to.

`inputStream`

A stream object for receiving data from the client.

`outputStream`

A stream object for sending data to the client.

## Discussion

When you publish a service, if you set the [`listenForConnections`](/documentation/Foundation/NetService/Options/listenForConnections) flag in the service options, the service object accepts connections on behalf of your app. Later, when a client connects to that service, the service object calls this method to provide the app with a pair of streams for communicating with that client.

---

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)