Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

gethostid(2)



  gethostname(2)                      CLIX                      gethostname(2)



  NAME

    gethostname, sethostname - Gets/sets name of current host

  LIBRARY

    Berkeley Software Distribution Library (libbsd.a)

  SYNOPSIS

    int gethostname(
      char *name ,
      int namelen );

    int sethostname(
      char *name ,
      int namelen );

  PARAMETERS

    name      Points to an array of characters.

    namelen   Specifies the size of the buffer to which name points.

  DESCRIPTION

    The gethostname() function returns the standard hostname for the host
    processor.  The namelen parameter specifies the size of the name array.
    The returned name is null-terminated unless insufficient space is
    provided.

    The sethostname() function establishes the name of the host machine to be
    name.  This call is allowed only to the superuser and is performed at boot
    time.

  EXAMPLES

    1.  To get the hostname:

        if (gethostname(name_buf, sizeof(name_buf)) == -1)
             perror("gethostname failed");


    2.  To set the hostname:

        if (sethostname(name_buf, sizeof(name_buf)) == -1)
             perror("sethostname failed");


  NOTES




  2/94 - Intergraph Corporation                                              1






  gethostname(2)                      CLIX                      gethostname(2)



    The maximum length for a hostname is 64 characters.

    Only the superuser can execute the sethostname() function.

  RETURN VALUES

    Upon successful completion, a value of 0 is returned.  Otherwise, a value
    of -1 is returned and errno is set to indicate the error.

  ERRORS

    These calls fail if one or more of the following is true:

    [EFAULT]   The name parameter specified an invalid address in the user
               address space.

    [EPERM]    The caller for sethostname() is not the superuser.

    [EINVAL]   The namelen parameter for sethostname is larger than the
               maximum size of a hostname.

  RELATED INFORMATION

    Functions:  gethostid(2)






























  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026