[Previous] [Contents] [Index] [Next]

gethostname()

Get the name of the current host

Synopsis:

#include <unix.h>

int gethostname( char * name, 
                 int namelen );

Library:

socket3r.lib, socket3s.lib

Description:

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.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EFAULT
Either name or namelen gave an invalid address.

Classification:

Standard Unix, POSIX 1003.1g (draft)

Safety:
Interrupt handler No
Signal handler No
Thread Yes

Caveats:

Hostnames are limited to MAXHOSTNAMELEN characters (defined in <sys/param.h>).

See also:

sethostname()


[Previous] [Contents] [Index] [Next]