The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

INHERITANCE

 POSIX::1003::Socket
   is a POSIX::1003::Module

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;

DESCRIPTION

[added in release 0.99] This module provides access to the "socket" interface, especially a long list of constants starting with SO_, SOL_, SOCK_, 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.

Extends "DESCRIPTION" in POSIX::1003::Module.

METHODS

Extends "METHODS" in POSIX::1003::Module.

POSIX::1003::Socket->exampleValue($name)

Inherited, see "METHODS" in POSIX::1003::Module

$obj->import()

Inherited, see "METHODS" in POSIX::1003::Module

FUNCTIONS

Standard POSIX

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

$obj->getsockopt($socket, $level, $opt)

Returns the value for $opt (some SO_ constant). See also setsockopt().

$obj->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 SO_DONTROUTE, SO_KEEPALIVE, and SO_REUSEADDR the value is treated as a real Perl boolean.

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

Additional

socket_names()

Returns a list with all known names, unsorted.

CONSTANTS

%socket

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

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.

export tag :so

  During installation, a symbol table will get inserted here.

export tag :sol

  During installation, a symbol table will get inserted here.

export tag :sock

  During installation, a symbol table will get inserted here.

export tag :af

  During installation, a symbol table will get inserted here.

export tag :pf

  During installation, a symbol table will get inserted here.

SEE ALSO

This module is part of POSIX-1003 distribution version 0.99_04, built on March 11, 2015. Website: http://perl.overmeer.net. The code is based on POSIX, which is released with Perl itself. See also POSIX::Util for additional functionality.

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 http://www.perl.com/perl/misc/Artistic.html