When does `inet:peername/1` return the `posix()` `einval`?
I assume that the underlaying syscall on linux is `getpeername()`, right?
From a more generic perspective, why isn’t it documented which are the `posix()` errors that can be actually returned by functions like `inet:peername/1`?
It can return einval when the documentation of your OS says that getpeername() can return einval. On my OS that is when the socket has been shutdown. In addition it can return einval if the logic in inet_get_address fails to parse the address.
Some function do that, but far from all. For example file:open/2 has a list of common errors and their reasons listed in its docs. I think for simple functions such as this it would be a good idea to just link to the opengroup documentation of the syscall.