Print this page
9704 move socket functions to libc

@@ -1,11 +1,14 @@
-SOCKADDR(3SOCKET)          Sockets Library Functions         SOCKADDR(3SOCKET)
+SOCKADDR(3C)             Standard C Library Functions             SOCKADDR(3C)
 
 NAME
      sockaddr, sockaddr_dl, sockaddr_in, sockaddr_in6, sockaddr_ll,
      sockaddr_storage, sockaddr_un - Socket Address Structures
 
+LIBRARY
+     Standard C Library (libc, -lc)
+
 SYNOPSIS
      #include <sys/socket.h>
 
      struct sockaddr sock;
 

@@ -38,14 +41,13 @@
 
 DESCRIPTION
      The sockaddr family of structures are designed to represent network
      addresses for different networking protocols.  The structure struct
      sockaddr is a generic structure that is used across calls to various
-     socket library routines (libsocket(3LIB)) such as accept(3SOCKET) and
-     bind(3SOCKET).  Applications do not use the struct sockaddr directly, but
-     instead cast the appropriate networking family specific sockaddr
-     structure to a struct sockaddr *.
+     socket routines such as accept(3C) and bind(3C).  Applications do not use
+     the struct sockaddr directly, but instead cast the appropriate networking
+     family specific sockaddr structure to a struct sockaddr *.
 
      Every structure in the sockaddr family begins with a member of the same
      type, the sa_family_t, though the different structures all have different
      names for the member.  For example, the structure struct sockaddr has the
      following members defined:

@@ -93,27 +95,27 @@
 
            sa_family_t     sin_family      /* address family */
            in_port_t       sin_port        /* IP port */
            struct in_addr  sin_addr        /* IP address */
 
-     The member sin_family must always have the value AF_INET for IPv4.  The
+     The member sin_family must always have the value AF_INET for IPv4 .  The
      members sin_port and sin_addr describe the IP address and IP port to use.
-     In the case of a call to connect(3SOCKET) these represent the remote IP
+     In the case of a call to connect(3C) these represent the remote IP
      address and port to which the connection is being made.  In the case of
-     bind(3SOCKET) these represent the IP address and port on the local host
-     to which the socket is to be bound.  In the case of accept(3SOCKET) these
+     bind(3C) these represent the IP address and port on the local host to
+     which the socket is to be bound.  In the case of accept(3C) these
      represent the remote IP address and port of the machine whose connection
      was accepted.
 
-     The member sin_port is always stored in Network Byte Order.  On many
+     The member sin_port is always stored in network byte order.  On many
      systems, this differs from the native host byte order.  Applications
-     should read from the member with the function ntohs(3SOCKET) and write to
-     the member with the function htons(3SOCKET).  The member sin_addr is the
-     four byte IPv4 address.  It is also stored in network byte order.  The
-     common way to write out the address is to use the function inet_pton(3C)
-     which converts between a human readable IP address such as "10.1.2.3" and
-     the corresponding representation.
+     should read from the member with the function ntohs(3C) and write to the
+     member with the function htons(3C).  The member sin_addr is the four byte
+     IPv4 address.  It is also stored in network byte order.  The common way
+     to write out the address is to use the function inet_pton(3C) which
+     converts between a human readable IP address such as `10.1.2.3' and the
+     corresponding representation.
 
      Example 1 shows how to prepare an IPv4 socket and deal with network byte-
      order.  See inet(7P) and ip(7P) for more information on IPv4, socket
      options, etc.
 

@@ -135,14 +137,14 @@
      The member sin6_family must always have the value AF_INET6.  The members
      sin6_port and sin6_addr are the IPv6 equivalents of the struct
      sockaddr_in sin_port and sin_addr.  Like their IPv4 counterparts, both of
      these members must be in network byte order.  The member sin6_port
      describes the IPv6 port and should be manipulated with the functions
-     ntohs(3SOCKET) and htons(3SOCKET).  The member sin6_addr describes the
-     16-byte IPv6 address.  In addition to the function inet_pton(3C), the
-     header file <netinet/in.h> defines many macros for manipulating and
-     testing IPv6 addresses.
+     ntohs(3C) and htons(3C).  The member sin6_addr describes the 16-byte IPv6
+     address.  In addition to the function inet_pton(3C), the header file
+     <netinet/in.h> defines many macros for manipulating and testing IPv6
+     addresses.
 
      The member sin6_flowinfo contains the traffic class and flow label
      associated with the IPv6 header.  The member sin6_scope_id may contain an
      identifier which varies based on the scope of the address in sin6_addr.
      Applications do not need to initialize sin6_scope_id; it will be

@@ -187,20 +189,20 @@
      interface is Ethernet which has the value IFT_ETHER.  The full set of
      types is derived from RFC1573 and recorded in the file <net/if_types.h>.
      The member sdl_slen describes the length of a selector, if it exists, for
      the specified medium.  This is used in protocols such as Trill.
 
-     The sdl_data, sdl_nlen and sdl_alen members together describe a character
-     string containing the interface name and the link-layer network address.
-     The name starts at the beginning of sdl_data, i.e. at sdl_data[0].  The
-     name of the interface occupies the next sdl_nlen bytes and is not NUL
-     terminated.  The link-layer network address begins immediately after the
-     interface name, and is sdl_alen bytes long.  The macro LLADDR(struct
-     sockaddr_dl *) returns the start of the link-layer network address.  The
-     interpretation of the link-layer address depends on the value of
-     sdl_type.  For example, if the type is IFT_ETHER then the address is
-     expressed as a 6-byte MAC address.
+     The sdl_data, sdl_nlen, and sdl_alen members together describe a
+     character string containing the interface name and the link-layer network
+     address.  The name starts at the beginning of sdl_data, i.e. at
+     sdl_data[0].  The name of the interface occupies the next sdl_nlen bytes
+     and is not NUL terminated.  The link-layer network address begins
+     immediately after the interface name, and is sdl_alen bytes long.  The
+     macro LLADDR(struct sockaddr_dl *) returns the start of the link-layer
+     network address.  The interpretation of the link-layer address depends on
+     the value of sdl_type.  For example, if the type is IFT_ETHER then the
+     address is expressed as a 6-byte MAC address.
 
    struct sockaddr_ll
      The sockaddr_ll is used as part of a socket type which is responsible for
      packet capture: AF_PACKET sockets.  It is generally designed for use with
      Ethernet networks.  The members of the struct sockaddr_ll are:

@@ -214,16 +216,16 @@
            uint8_t         sll_addr[8];    /* hardware type */
 
      The member sll_family must be AF_PACKET.  The member sll_protocol refers
      to a link-layer protocol.  For example, when capturing Ethernet frames
      the value of sll_protocol is the Ethertype.  This member is written in
-     network byte order and applications should use htons(3SOCKET) and
-     ntohs(3SOCKET) to read and write the member.
+     network byte order and applications should use htons(3C) and ntohs(3C) to
+     read and write the member.
 
      The member sll_ifindex is the interface's index.  It is used as an
      identifier in various ioctls and included in the output of ifconfig(1M).
-     When calling bind(3SOCKET) it should be filled in with the index that
+     When calling bind(3C) it should be filled in with the index that
      corresponds to the interface for which packets should be captured on.
 
      The member sll_pkttype describes the type of the packet based on a list
      of types in the header file <netpacket/packet.h>.  These types include:
      PACKET_OUTGOING, a packet that was leaving the host and has been looped

@@ -238,17 +240,14 @@
      contains the length, in bytes, of the hardware address, while the member
      sll_addr contains the actual address in network byte order.
 
 EXAMPLES
      Example 1 Preparing an IPv4 sockaddr_in to connect to a remote host
+             The following example shows how one would open a socket and
+             prepare it to connect to the remote host whose address is the IP
+             address 127.0.0.1 on port 80.
 
-     The following example shows how one would open a socket and prepare it to
-     connect to the remote host whose address is the IP address 127.0.0.1 on
-     port 80.  This program should be compiled with the C compiler cc and
-     linked against the libraries libsocket and libnsl.  If this example was
-     named ip4.c, then the full link line would be cc ip4.c -lsocket -lnsl.
-
      #include <sys/types.h>
      #include <sys/socket.h>
      #include <stdio.h>
      #include <netinet/in.h>
      #include <inttypes.h>

@@ -283,17 +282,14 @@
 
              return (0);
      }
 
      Example 2 Preparing an IPv6 sockaddr_in6 to bind to a local address
+             The following example shows how one would open a socket and
+             prepare it to bind to the local IPv6 address ::1 port on port
+             12345.
 
-     The following example shows how one would open a socket and prepare it to
-     bind to the local IPv6 address ::1 port on port 12345.  This program
-     should be compiled with the C compiler cc and linked against the
-     libraries libsocket and libnsl.  If this example was named ip6.c, then
-     the full compiler line would be cc ip6.c -lsocket -lnsl.
-
      #include <sys/types.h>
      #include <sys/socket.h>
      #include <stdio.h>
      #include <netinet/in.h>
      #include <inttypes.h>

@@ -328,10 +324,9 @@
 
              return (0);
      }
 
 SEE ALSO
-     socket(3HEAD), un.h(3HEAD), accept(3SOCKET), bind(3SOCKET),
-     connect(3SOCKET), socket(3SOCKET), arp(7P), inet(7P), inet6(7P), ip(7P),
-     ip6(7P)
+     accept(3C), bind(3C), connect(3C), socket(3C), socket.h(3HEAD),
+     un.h(3HEAD), arp(7P), inet(7P), inet6(7P), ip(7P), ip6(7P)
 
-illumos                          April 9, 2016                         illumos
+illumos                         August 2, 2018                         illumos