=encoding utf8

=head1 NAME

POSIX::1003::Socket - POSIX constants and functions related to sockets

=head1 SYNOPSIS

  # SOCKET support

  use POSIX::1003::Socket; # load all names
  socket(Server, PF_INET, SOCK_STREAM, $proto);
  setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, 1);

  use POSIX::1003::Socket qw(SOCK_DGRAM);
  print SOCK_DGRAM;        # constants are subs

  use POSIX::1003::Socket '%socket';
  my $bits = $socket{SOCK_DGRAM};
  $socket{SOCK_DGRAM} = $bits;

  print "$_\n" for keys %socket;

=head1 DESCRIPTION

[added in release 0.99]
This module provides access to the "socket" interface, especially a
long list of constants starting with C<SO_>, C<SOL_>, C<SOCK_>, C<AF_>,
and many more.

The best way to work with sockets is via IO::Socket::IP.  This module
provides many more constants than those modules do, but currently does
not export the functions as the other modules of this suite do.

The advantage of using the constants of this module, is that the list
will be extended when new names are discovered, and then immediately
available to older versions of Perl.

=head1 METHODS

=head1 FUNCTIONS

=head2 Standard POSIX

Many socket related functions are contained in Perl's core.

=over 4

=item $obj-E<gt>B<getsockopt>($socket, $level, $opt)

Returns the value for $opt (some SO_ constant).  See also L<setsockopt()|POSIX::1003::Socket/"Standard POSIX">.

=item $obj-E<gt>B<setsockopt>($socket, $level, $opt, $value)

Set the $value on $opt for the $socket.

There are a few minor tricks to make this function integrate better in
Perl.  Firstly, for the boolean OPTs C<SO_DONTROUTE>, C<SO_KEEPALIVE>,
and C<SO_REUSEADDR> the value is treated as a real Perl boolean.

C<SO_LINGER> has three combinations.  "Linger off" is reprensed by 
Other values mean "linger on" with a timeout.
C<SO_RCVTIMEO> and C<SO_SNDTIME> get a timestamp in float.

=back

=head2 Additional

=over 4

=item B<socket_names>()

Returns a list with all known names, unsorted.

=back

=head1 CONSTANTS

=over 4

=item B<%socket>

This exported variable is a tied HASH which maps C<SO*> and C<AF_*>
names to numbers, to be used with various socket related functions.

=back

The following constants where detected on your system when the module
got installed.  The second column shows the value which where returned
at that time.

=head2 export tag :so

=for comment
#TABLE_SOCKET_SO_START

  SO_ACCEPTCONN                     30
  SO_ATTACH_FILTER                  26
  SO_BINDTODEVICE                   25
  SO_BROADCAST                      6
  SO_DEBUG                          1
  SO_DETACH_FILTER                  27
  SO_DOMAIN                         39
  SO_DONTROUTE                      5
  SO_ERROR                          4
  SO_KEEPALIVE                      9
  SO_LINGER                         13
  SO_MARK                           36
  SO_NO_CHECK                       11
  SO_NOFCS                          43
  SO_OOBINLINE                      10
  SO_PASSCRED                       16
  SO_PASSSEC                        34
  SO_PEEK_OFF                       42
  SO_PEERCRED                       17
  SO_PEERNAME                       28
  SO_PEERSEC                        31
  SO_PRIORITY                       12
  SO_PROTOCOL                       38
  SO_RCVBUF                         8
  SO_RCVBUFFORCE                    33
  SO_RCVLOWAT                       18
  SO_RCVTIMEO                       20
  SO_REUSEADDR                      2
  SO_RXQ_OVFL                       40
  SO_SECURITY_AUTHENTICATION        22
  SO_SECURITY_ENCRYPTION_NETWORK    24
  SO_SECURITY_ENCRYPTION_TRANSPORT  23
  SO_SNDBUF                         7
  SO_SNDBUFFORCE                    32
  SO_SNDLOWAT                       19
  SO_SNDTIMEO                       21
  SO_TIMESTAMP                      29
  SO_TIMESTAMPING                   37
  SO_TIMESTAMPNS                    35
  SO_TYPE                           3
  SO_WIFI_STATUS                    41


=for comment
#TABLE_SOCKET_SO_END

=head2 export tag :sol

=for comment
#TABLE_SOCKET_SOL_START

  SOL_AAL     265       SOL_IP      0         SOL_RAW     255
  SOL_ATM     264       SOL_IPV6    41        SOL_SOCKET  1
  SOL_DECNET  261       SOL_IRDA    266       SOL_X25     262
  SOL_ICMPV6  58        SOL_PACKET  263       


=for comment
#TABLE_SOCKET_SOL_END

=head2 export tag :sock

=for comment
#TABLE_SOCKET_START

  AI_ADDRCONFIG                32
  AI_ALL                       16
  AI_CANONIDN                  128
  AI_CANONNAME                 2
  AI_IDN                       64
  AI_IDN_ALLOW_UNASSIGNED      256
  AI_IDN_USE_STD3_ASCII_RULES  512
  AI_NUMERICHOST               4
  AI_NUMERICSERV               1024
  AI_PASSIVE                   1
  AI_V4MAPPED                  8
  EAI_ADDRFAMILY               -9
  EAI_AGAIN                    -3
  EAI_BADFLAGS                 -1
  EAI_FAIL                     -4
  EAI_FAMILY                   -6
  EAI_NODATA                   -5
  EAI_NONAME                   -2
  EAI_SERVICE                  -8
  EAI_SOCKTYPE                 -7
  EAI_SYSTEM                   -11
  INADDR_ANY                   0
  INADDR_BROADCAST             4294967295
  INADDR_LOOPBACK              2130706433
  INADDR_NONE                  4294967295
  IOV_MAX                      1024
  IP_HDRINCL                   3
  IP_MTU_DISCOVER              10
  IP_OPTIONS                   4
  IP_RECVOPTS                  6
  IP_RECVRETOPTS               7
  IP_RETOPTS                   7
  IP_TOS                       1
  IP_TTL                       2
  IPPROTO_ICMP                 1
  IPPROTO_IP                   0
  IPPROTO_IPV6                 41
  IPPROTO_RAW                  255
  IPPROTO_TCP                  6
  IPPROTO_UDP                  17
  IPV6_ADD_MEMBERSHIP          20
  IPV6_DROP_MEMBERSHIP         21
  IPV6_MTU                     24
  IPV6_MTU_DISCOVER            23
  IPV6_MULTICAST_HOPS          18
  IPV6_MULTICAST_IF            17
  IPV6_MULTICAST_LOOP          19
  IPV6_UNICAST_HOPS            16
  IPV6_V6ONLY                  26
  MSG_CTRUNC                   8
  MSG_DONTROUTE                4
  MSG_DONTWAIT                 64
  MSG_EOR                      128
  MSG_ERRQUEUE                 8192
  MSG_FIN                      512
  MSG_NOSIGNAL                 16384
  MSG_OOB                      1
  MSG_PEEK                     2
  MSG_PROXY                    16
  MSG_RST                      4096
  MSG_SYN                      1024
  MSG_TRUNC                    32
  MSG_WAITALL                  256
  NI_DGRAM                     16
  NI_IDN                       32
  NI_IDN_ALLOW_UNASSIGNED      64
  NI_IDN_USE_STD3_ASCII_RULES  128
  NI_NAMEREQD                  8
  NI_NOFQDN                    4
  NI_NUMERICHOST               1
  NI_NUMERICSERV               2
  SCM_CREDENTIALS              2
  SCM_RIGHTS                   1
  SCM_TIMESTAMP                29
  SHUT_RD                      0
  SHUT_RDWR                    2
  SHUT_WR                      1
  SOCK_CLOEXEC                 524288
  SOCK_DCCP                    6
  SOCK_DGRAM                   2
  SOCK_NONBLOCK                2048
  SOCK_PACKET                  10
  SOCK_RAW                     3
  SOCK_RDM                     4
  SOCK_SEQPACKET               5
  SOCK_STREAM                  1
  SOMAXCONN                    128
  UIO_MAXIOV                   1024


=for comment
#TABLE_SOCKET_END

=head2 export tag :af

=for comment
#TABLE_SOCKET_AF_START

  AF_ALG         38     AF_INET        2      AF_PACKET      17
  AF_APPLETALK   5      AF_INET6       10     AF_PHONET      35
  AF_ASH         18     AF_IPX         4      AF_PPPOX       24
  AF_ATMPVC      8      AF_IRDA        23     AF_RDS         21
  AF_ATMSVC      20     AF_ISDN        34     AF_ROSE        11
  AF_AX25        3      AF_IUCV        32     AF_ROUTE       16
  AF_BLUETOOTH   31     AF_KEY         15     AF_RXRPC       33
  AF_BRIDGE      7      AF_LLC         26     AF_SECURITY    14
  AF_CAIF        37     AF_LOCAL       1      AF_SNA         22
  AF_CAN         29     AF_MAX         40     AF_TIPC        30
  AF_DECnet      12     AF_NETBEUI     13     AF_UNIX        1
  AF_ECONET      19     AF_NETLINK     16     AF_UNSPEC      0
  AF_FILE        1      AF_NETROM      6      AF_WANPIPE     25
  AF_IEEE802154  36     AF_NFC         39     AF_X25         9


=for comment
#TABLE_SOCKET_AF_END

=head2 export tag :pf

=for comment
#TABLE_SOCKET_PF_START

  PF_ALG         38     PF_INET        2      PF_PACKET      17
  PF_APPLETALK   5      PF_INET6       10     PF_PHONET      35
  PF_ASH         18     PF_IPX         4      PF_PPPOX       24
  PF_ATMPVC      8      PF_IRDA        23     PF_RDS         21
  PF_ATMSVC      20     PF_ISDN        34     PF_ROSE        11
  PF_AX25        3      PF_IUCV        32     PF_ROUTE       16
  PF_BLUETOOTH   31     PF_KEY         15     PF_RXRPC       33
  PF_BRIDGE      7      PF_LLC         26     PF_SECURITY    14
  PF_CAIF        37     PF_LOCAL       1      PF_SNA         22
  PF_CAN         29     PF_MAX         40     PF_TIPC        30
  PF_DECnet      12     PF_NETBEUI     13     PF_UNIX        1
  PF_ECONET      19     PF_NETLINK     16     PF_UNSPEC      0
  PF_FILE        1      PF_NETROM      6      PF_WANPIPE     25
  PF_IEEE802154  36     PF_NFC         39     PF_X25         9


=for comment
#TABLE_SOCKET_PF_END

=head1 SEE ALSO

This module is part of POSIX-1003 distribution version 0.99_01,
built on January 31, 2015. Website: F<http://perl.overmeer.net>.  The code is based on L<POSIX>, which
is released with Perl itself.  See also L<POSIX::Util> for
additional functionality.

=head1 COPYRIGHTS

Copyrights 2011-2015 on the perl code and the related documentation
 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>

