Get the name of the current host
#include <unistd.h> int gethostname( char * name, size_t namelen );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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.
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
Hostnames are limited to MAXHOSTNAMELEN characters (defined in <sys/param.h>).