Gets the effective user ID and effective group ID of a peer on a connected UNIX domain socket.
The getpeereid subroutine returns the effective user and group IDs of the peer connected to a stream socket in the UNIX domain. The effective user and group IDs are saved in the socket, to be returned, when the peer calls connect or listen.
| Item | Description |
|---|---|
| socket | Specifies the descriptor number of a connected socket. |
| euid | The effective user ID of the peer socket. |
| egid | The effective group ID of the peer socket. |
When the getpeereid subroutine successfully completes, a value of 0 is returned and the euid and egid parameters hold the effective user ID and group ID, respectively.
If the getpeereid subroutine is unsuccessful, the system handler returns a value of -1 to the calling program and sets the errno global variable to an error code that indicates the specific error.
| Item | Description |
|---|---|
| EBADF | The socket parameter is not valid. |
| ENOTSOCK | The socket parameter refers to a file, not a socket. |
| ENOTCONN | The socket is not connected. |
| ENOBUFS | Insufficient resources were available in the system to complete the call. |
| EFAULT | The address parameter is not in a writable part of the user address space. |