<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Virtualization",
  "identifier" : "/documentation/Virtualization/VZVirtioSocketDevice",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Virtualization"
    ],
    "preciseIdentifier" : "c:objc(cs)VZVirtioSocketDevice"
  },
  "title" : "VZVirtioSocketDevice"
}
-->

# VZVirtioSocketDevice

A device that manages port-based connections between the guest system and the host computer.

```
class VZVirtioSocketDevice
```

## Overview

Use a [`VZVirtioSocketDevice`](/documentation/Virtualization/VZVirtioSocketDevice) object to configure services and other communication end points in your virtual machine. Host computers make services available using ports, which identify the type of service and the protocol to use when transmitting data. Use this object to specify the ports available to your guest operating system, and to register handlers to manage the communication on those ports.

Don’t create a [`VZVirtioSocketDevice`](/documentation/Virtualization/VZVirtioSocketDevice) object directly. Instead, when you request a socket device in your configuration, the virtual machine creates it and stores it in the [`socketDevices`](/documentation/Virtualization/VZVirtualMachine/socketDevices) property. For each port you want to make available in your virtual machine, call the [`setSocketListener(_:forPort:)`](/documentation/Virtualization/VZVirtioSocketDevice/setSocketListener(_:forPort:)) method and provide an object to manage the port connections.

## Topics

### Configuring Port Listeners

[`setSocketListener(_:forPort:)`](/documentation/Virtualization/VZVirtioSocketDevice/setSocketListener(_:forPort:))

Configures an object to monitor the specified port for new connections.

[`removeSocketListener(forPort:)`](/documentation/Virtualization/VZVirtioSocketDevice/removeSocketListener(forPort:))

Removes the listener object from the specfied port.

### Connecting to Guest System Ports

[`connect(toPort:completionHandler:)`](/documentation/Virtualization/VZVirtioSocketDevice/connect(toPort:completionHandler:))

Initiates a connection to the specified port of the guest operating system.

[`connect(toPort:)`](/documentation/Virtualization/VZVirtioSocketDevice/connect(toPort:))

Initiates a connection to the specified port of the guest operating system.



---

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)