z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


gethostname()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The gethostname() call returns the name of the host processor on which the program is running. Characters to the limit of namelen are copied into the name array. The value returned for host name is limited to 24 characters. The returned name is NULL-terminated unless truncated to the size of the name array.
Note: The host name returned is the host name the TCPIP stack learned at startup from the TCPIP.DATA file that was found.

This call can be used only in the AF_INET domain.

Errno EINVAL is returned when namelen is 0, or greater than 255 characters.

#include <manifest.h>
#include <socket.h>
int gethostname(char *name, int namelen)
Parameter
Description
name
Character array to be filled with the host name
namelen
Length of name; restricted to 255 characters

Return values

The value 0 indicates success; the value -1 indicates an error. Errno identifies the specific error.
Errno
Description
EFAULT
The name parameter specified an address outside the caller address space.

Related calls

gethostbyname(), gethostid()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014