# libtmux::socket_from_environment

- **Module:** libtmux
- **Package:** libtmux-cxx
- **Language:** C++
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-cxx/blob/542fdc204ff3cfa56f5484327cda0c69bad2307d/include/libtmux/socket.hpp#L148
- **Page:** https://libtmux.org/en/cxx/latest/reference/libtmux-socket_from_environment/

```
[[nodiscard]] EnvironmentSocket socket_from_environment();
```

Reads `LIBTMUX_SOCKET_PATH`, then `LIBTMUX_SOCKET`.

The path wins when both are set, as tmux's `-S` overrides `-L`. A variable that is empty or only whitespace counts as unset, each one alone, so an empty path leaves a set name in force. Any other value is returned as it was given. `TMUX` is not read: tmux follows it by itself when no socket is passed.
