---
title: "listener(_:shouldAcceptNewConnection:from:)"
framework: virtualization
role: symbol
role_heading: Instance Method
path: "virtualization/vzvirtiosocketlistenerdelegate/listener(_:shouldacceptnewconnection:from:)"
---

# listener(_:shouldAcceptNewConnection:from:)

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

## Declaration

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

Return Value true to establish the connection, or false to reject it.

## Discussion

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 false.
