get the name of the current host
#include <unix.h> int gethostname( char *name, int namelen );
The gethostname() function stores in name the standard hostname for the current processor, as previously set by sethostname(). The parameter namelen specifies the size of the name array. The returned name is null-terminated unless insufficient space is provided.
If an error occurred, errno could contain one of the following:
POSIX 1003.1g (draft)
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
Hostnames are limited to MAXHOSTNAMELEN characters (defined in <sys/param.h>).