---
title: "netService(_:didAcceptConnectionWith:outputStream:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/netservicedelegate/netservice(_:didacceptconnectionwith:outputstream:)"
---

# netService(_:didAcceptConnectionWith:outputStream:)

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

## Declaration

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

Discussion When you publish a service, if you set the 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.
