The gethostname( ) and sethostname( ) functions get and set the local host name.
int gethostname( char *name, int len ); int sethostname( char *name, int len );
gethostname( ) retrieves the host name and places it in the character string pointed to by the argument name. The len is the maximum number of characters of the name that can be returned; it should be set to the size of name. If the host name is longer than len, it will be truncated; it will be null terminated only if the name is shorter than len.
sethostname( ) sets the host name to the argument name. Only the Super user can set the host name.
0
(zero)
-1
and the function sets errno to one of these values:
EFAULT |
name is null. |
EINVAL |
For gethostname, len is 0 (zero) or less than the length of the actual host name's length. For sethostname, len is 0 (zero) or greater than the length of the actual host name's maximum length. |
EPERM |
Permission denied. |
ENODEV |
Stack is not running. |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/arpa/inet.h | arpa/inet.h | netiff3m.lib |