> ## 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 TypeScript 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

```typescript theme={null}
import { Sandbox } from "microsandbox";

await using sandbox = await Sandbox.builder("worker")
  .image("alpine")
  .vsock("/run/host-api.sock", 5000)
  .create();
```

## SandboxBuilder

### vsock()

```typescript theme={null}
vsock(hostPath: string, port: number): this
```

Expose a host Unix stream socket or local Windows named pipe on host CID `2` at `port`.

### vsockDgram()

```typescript theme={null}
vsockDgram(hostPath: string, port: number): this
```

Expose a host Unix datagram socket while preserving datagram boundaries. Datagram routes are unavailable on Windows.

Both methods can be called repeatedly to add routes. Host paths must be absolute, and each socket type and port pair must be unique.


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