# sockaddr

## NAME



           sockaddr, sockaddr_storage, sockaddr_in, sockaddr_in6,
           sockaddr_un, socklen_t, in_addr, in6_addr, in_addr_t, in_port_t, -
           socket address
    


## LIBRARY



           Standard C library (_libc_)
    


## SYNOPSIS



           **#include <sys/socket.h>**
    
           **struct sockaddr {**
               **sa_family_t     sa_family;** /* Address family */
               **char            sa_data[];** /* Socket address */
           **};**
    
           **struct sockaddr_storage {**
               **sa_family_t     ss_family;** /* Address family */
           **};**
    
           **typedef** /* ... */ **socklen_t;**
           **typedef** /* ... */ **sa_family_t;**
    
       **Internet domain sockets**
           **#include <netinet/in.h>**
    
           **struct sockaddr_in {**
               **sa_family_t     sin_family;** /* **AF_INET** */
               **in_port_t       sin_port;** /* Port number */
               **struct in_addr  sin_addr;** /* IPv4 address */
           **};**
    
           **struct sockaddr_in6 {**
               **sa_family_t     sin6_family;** /* **AF_INET6** */
               **in_port_t       sin6_port;** /* Port number */
               **uint32_t        sin6_flowinfo;** /* IPv6 flow info */
               **struct in6_addr sin6_addr;** /* IPv6 address */
               **uint32_t        sin6_scope_id;** /* Set of interfaces for a scope */
           **};**
    
           **struct in_addr {**
               **in_addr_t s_addr;**
           **};**
    
           **struct in6_addr {**
               **uint8_t   s6_addr[16];**
           **};**
    
           **typedef uint32_t in_addr_t;**
           **typedef uint16_t in_port_t;**
    
       **UNIX domain sockets**
           **#include <sys/un.h>**
    
           **struct sockaddr_un {**
               **sa_family_t     sun_family;** /* Address family */
               **char            sun_path[];** /* Socket pathname */
           **};**
    


## DESCRIPTION



           _sockaddr_
                  Describes a socket address.
    
           _sockaddr_storage_
                  A structure at least as large as any other _sockaddr__ *
                  address structures.  It's aligned so that a pointer to it
                  can be cast as a pointer to other _sockaddr__ * structures and
                  used to access its fields.
    
           _socklen_t_
                  Describes the length of a socket address.  This is an
                  integer type of at least 32 bits.
    
           _sa_family_t_
                  Describes a socket's protocol family.  This is an unsigned
                  integer type.
    
       **Internet domain sockets**
           _sockaddr_in_
                  Describes an IPv4 Internet domain socket address.  The
                  _sin_port_ and _sin_addr_ members are stored in network byte
                  order.
    
           _sockaddr_in6_
                  Describes an IPv6 Internet domain socket address.  The
                  _sin6_addr.s6_addr_ array is used to contain a 128-bit IPv6
                  address, stored in network byte order.
    
       **UNIX domain sockets**
           _sockaddr_un_
                  Describes a UNIX domain socket address.
    


## STANDARDS



           POSIX.1-2008.
    


## NOTES



           _socklen_t_ is also defined in _< netdb.h>_.
    
           _sa_family_t_ is also defined in _< netinet/in.h>_ and _< sys/un.h>_.
    


* * *