> ## Documentation Index
> Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# VSock

> Connect a sandbox to host Unix sockets or local Windows named pipes over virtio-vsock with the Python SDK.

See [Host sockets](/networking/host-sockets) for guest connection details, platform support, and security considerations.

<Note>VSock routes are local-only and unavailable with the multi-tenant deployment profile.</Note>

## Typical flow

```python theme={null}
from microsandbox import Sandbox

sandbox = await Sandbox.create(
    "worker",
    image="alpine",
    vsock={"/run/host-api.sock": 5000},
)
```

## Sandbox.create()

| Parameter | Type | Default | Description |
| - | - | - | - |
| `vsock` | `Mapping[str, int] \| Sequence[VsockRoute] \| None` | `None` | Host IPC routes exposed on guest host-CID ports |

A mapping creates stream routes. Use typed [`VsockRoute`](#vsockroute) values for datagram routes or when the socket type should be explicit.

## VsockRoute

```python theme={null}
VsockRoute(host_socket, port, socket_type=VsockSocketType.STREAM)
```

Frozen route configuration imported from `microsandbox`.

| Class method | Returns | Description |
| - | - | - |
| `stream(host_socket, port)` | `VsockRoute` | Create a stream route |
| `dgram(host_socket, port)` | `VsockRoute` | Create a datagram route |

Datagram routes are unavailable on Windows. Host paths must be absolute, and each socket type and port pair must be unique.

## VsockSocketType

String enum imported from `microsandbox`.

| Member | Value | Description |
| - | - | - |
| `STREAM` | `"stream"` | Reliable, ordered byte stream; the default |
| `DGRAM` | `"dgram"` | Best-effort messages with preserved datagram boundaries |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.