Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bind(2)

socket(2)



  getsockname(2)                      CLIX                      getsockname(2)



  NAME

    getsockname - Gets the name of a socket

  LIBRARY

    Berkeley Software Distribution Library (libbsd.a)

  SYNOPSIS

    #include <sys/types.h>

    #include <sys/socket.h>

    int getsockname(
      int s ,
      struct sockaddr *name ,
      int *namelen );

  PARAMETERS

    s         Specifies a socket descriptor.

    name      Points to the structure that will contain the name of the socket
              upon return.

    namelen   Specifies the amount of space pointed to by name.

  DESCRIPTION

    The getsockname() function returns the current name for the specified
    socket obtained from socket().  The namelen parameter should be
    initialized to indicate the amount of space pointed to by name.  On
    return, namelen contains the actual size of the name returned (in bytes).

  EXAMPLES

    To get the name of socket sd:

    struct sockaddr_in addr;
    int size;
    size = sizeof(struct sockaddr_in);
    if (getsockname(sd, (struct sockaddr *)&addr, &size) == -1)
         perror("Getsockname failed");


  NOTES

    Names bound to sockets in the UNIX domain are inaccessible; the
    getsockname() function returns a zero-length name.




  2/94 - Intergraph Corporation                                              1






  getsockname(2)                      CLIX                      getsockname(2)



  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

    The getsockname() function fails if one or more of the following is true:

    [EBADF]      The descriptor is invalid.

    [ENOTSOCK]   The descriptor references a file, not a socket.

    [EFAULT]     The name parameter points to memory not in a writable part of
                 the user address space.

  RELATED INFORMATION

    Functions:  bind(2), socket(2)



































  2                                              Intergraph Corporation - 2/94




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