unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

GETHOSTNAME(2)                System Calls Manual               GETHOSTNAME(2)



NAME
       gethostname, sethostname - get/set name of current host

SYNOPSIS
       int gethostname(name, namelen)
       char *name;
       int namelen;

       int sethostname(name, namelen)
       char *name;
       int namelen;

DESCRIPTION
       gethostname() returns the standard host name for the current processor,
       as previously set by sethostname().  The  parameter  namelen  specifies
       the  size  of the array pointed to by name.  The returned name is null-
       terminated unless insufficient space is provided.

       sethostname() sets the name of the host machine to be name,  which  has
       length  namelen.  This call is restricted to the super-user and is nor-
       mally used only when the system is bootstrapped.

RETURN VALUES
       gethostname() and sethostname() return:

       0      on success.

       -1     on failure and set errno to indicate the error.

ERRORS
       EFAULT         The name or namelen parameter gave an invalid address.

       In addition to the above, sethostname() may set errno to:

       EPERM          The caller was not the super-user.

SEE ALSO
       gethostid(2)

NOTES
       Host names are limited to MAXHOSTNAMELEN (from  <&lt;sys/param.h>&gt;)  charac-
       ters, currently 64.



                                21 January 1990                 GETHOSTNAME(2)