# io.github.libtmux.Server.control

- **Module:** io.github.libtmux
- **Package:** io.github.libtmux:libtmux
- **Language:** Java
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-java/blob/f56392b5d9bc7f1f9c1631842333fb90f3d82d40/libtmux/src/main/java/io/github/libtmux/Server.java#L815
- **Page:** https://libtmux.org/en/java/latest/reference/io-github-libtmux-server-server-control/

```
io.github.libtmux.Server.control(session: Session) -> ControlClient

io.github.libtmux.Server.control(session: Session, timeout: Duration) -> ControlClient
```

Attaches a control client to this session's server, and only to the process this capture named.

The client is started by this server's transport. A transport that cannot start processes
fails here rather than attaching on the local machine. The process id is checked before the
client starts and again on the client itself; a server that has taken over the socket is
detached before this client changes it.

## Parameters

- `session` (`Session`): a session captured from this server (for `control(session)`)
- `timeout` (`Duration`): how long to wait for the client to become ready (for `control(session, timeout)`)

## Raises

- [`TargetGoneException`](/en/java/latest/reference/io-github-libtmux-exception-targetgoneexception-targetgoneexception/): if that process is no longer the one on this socket (for `control(session)`)
- [`IllegalArgumentException`](https://docs.oracle.com/en/java/javase/21/docs/api/java/lang/IllegalArgumentException.html): if the session belongs to another server (for `control(session)`)
- [`IllegalStateException`](https://docs.oracle.com/en/java/javase/21/docs/api/java/lang/IllegalStateException.html): if this server is closed, or its transport starts no control client (for `control(session)`)
