# libtmux.Server._socket_args

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/efdbb5637666b166358772ecc737b3807beab21e/src/libtmux/server.py#L938
- **Page:** https://libtmux.org/en/py/latest/reference/libtmux-server-_socket_args/

```
libtmux.Server._socket_args(self) -> list[str]
```

Return this server's ``-S``/``-L`` flags, measuring the socket path.

Every path that spawns tmux for this server builds its argv from here,
which is what makes the measurement total: a socket flag cannot reach
tmux without having been measured on the way.

A tmux socket is a UNIX domain socket, so its path has to fit in
:data:`~libtmux._internal.env.SOCKET_PATH_MAX_BYTES`. An explicit
:attr:[`socket_path`](/en/tmux/latest/catalog/formats/socket_path/) is settled the moment it is passed and is measured
in ``__init__``; measuring it again here is free and keeps this method
total over every flag it renders.

A name or a bare server is different, and is measured only here, for
the same reason ``colors`` is checked at this point: naming a server is
not using one, so :meth:`is_alive` has to stay answerable for a server
that cannot be reached. It also reads ``$TMUX_TMPDIR`` at the moment
the tmux binary would read it, so an environment changed after
construction is measured as tmux sees it rather than as it once was.

## Returns

list[str]
    ``["-S<path>"]``, ``["-L<name>"]``, or ``[]`` for a bare server,
    which leaves tmux to pick the socket itself -- ``$TMUX`` inside a
    pane, and a path under ``$TMUX_TMPDIR`` outside one.

## Raises

- [`SocketPathTooLong`](/en/py/latest/reference/libtmux-exc-socketpathtoolong/): When the socket path -- given, or resolved from ``socket_name`` --
cannot fit in a UNIX socket address.

## Examples

```python
>>> server._socket_args()
['-Llibtmux_test...']
```

```python
>>> from libtmux.server import Server as TmuxServer
>>> TmuxServer(socket_path="/tmp/short/sock")._socket_args()
['-S/tmp/short/sock']
```

A bare server names no socket, and tmux falls back to its own default:

```python
>>> TmuxServer()._socket_args()
[]
```

A path too long to bind is refused here, before tmux is spawned:

```python
>>> try:
...     TmuxServer(socket_path="/tmp/" + "d" * 120 + "/sock")._socket_args()
... except exc.SocketPathTooLong as e:
...     print(e.length)
130
```
