<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Tor",
  "identifier" : "/documentation/Tor/TorClient/control()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Tor"
    ],
    "preciseIdentifier" : "s:3Tor0A6ClientC7controlAA0a7ControlB0CyKF"
  },
  "title" : "control()"
}
-->

# control()

Return the [`TorControlClient`](/documentation/Tor/TorControlClient) bound to this Tor instance.

```
func control() throws -> TorControlClient
```

## Return Value

The shared [`TorControlClient`](/documentation/Tor/TorControlClient). The same instance is
returned across calls for the life of the session.

## Discussion

Hands out the shared, pre-authenticated control client that
swift-tor creates during [`start()`](/documentation/Tor/TorClient/start()). Use it for advanced
operations the high-level API does not expose: `GETINFO` queries
beyond the curated list, raw `SETEVENTS` subscriptions, onion-
service management ([`addOnion(key:ports:detach:)`](/documentation/Tor/TorControlClient/addOnion(key:ports:detach:))),
and Tor signals (`NEWNYM`, `DUMP`, etc.).

> Throws: ``doc://Tor/documentation/Tor/TorError/controlUnavailable`` when Tor is not running
> or the control socket failed to authenticate during start.

> Important: The returned client is owned by this `TorClient`.
> Do not close its socket manually — that is handled by
> ``doc://Tor/documentation/Tor/TorClient/stop()``. Calling control commands concurrently is safe;
> commands are serialised at the socket layer.