<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Virtualization",
  "identifier" : "/documentation/Virtualization/VZVirtioSocketListenerDelegate/listener(_:shouldAcceptNewConnection:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Virtualization"
    ],
    "preciseIdentifier" : "c:objc(pl)VZVirtioSocketListenerDelegate(im)listener:shouldAcceptNewConnection:fromSocketDevice:"
  },
  "title" : "listener(_:shouldAcceptNewConnection:from:)"
}
-->

# listener(_:shouldAcceptNewConnection:from:)

Returns a Boolean value that indicates whether to accept a new connection from the guest operating system.

```
optional func listener(_ listener: VZVirtioSocketListener, shouldAcceptNewConnection connection: VZVirtioSocketConnection, from socketDevice: VZVirtioSocketDevice) -> Bool
```

## Parameters

`listener`

The listener object that monitors the associated port.

`connection`

The object that contains information about the proposed connection. Use this object to fetch port information.

`socketDevice`

The Virtio socket device that requested the connection.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to establish the connection, or <doc://com.apple.documentation/documentation/Swift/false> to reject it.

## Discussion

Use your method’s implementation to quickly determine whether to accept or reject connection attempts. A typical implementation verifies that a connection between the specified ports is permissible. Return a result as quickly as possible, and don’t perform any long-running operations in this method.

If you don’t implement this method, the virtual machine refuses all connection requests as if this method returned <doc://com.apple.documentation/documentation/Swift/false>.

---

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)