VMS Help
TCPIP Services, Programming Interfaces, Sockets API, socket()

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

    Creates an endpoint for communication by returning a special
    kind of file descriptor called a socket descriptor, which is
    associated with a TCP/IP Services socket device channel.
    The $QIO equivalent is the IO$_SETMODE function.
    Format
      #include  <types.h>
      #include  <socket.h>
      int socket  ( int af, int type, int protocol );

  1 - Arguments

 af
    The address family used in later references to the socket.
    Addresses specified in subsequent operations using the socket
    are interpreted according to this family. Currently, only the AF_
    INET (internet) and TCPIP$C_AUXS addresses are supported.
    For a network application server with the LISTEN flag enabled,
    you specify the TCPIP$C_AUXS address family to obtain the
    connected device socket created by the auxiliary server in
    response to incoming network traffic. For an example of this
    situation, refer to the example in <REFERENCE>(EX_TCP_ASRV_SOCK).
 type
    The socket types are:
    o  SOCK_STREAM - Provides sequenced, reliable, two-way,
       connection-based byte streams with an available out-of-band
       data transmission mechanism.
    o  SOCK_DGRAM - Supports datagrams (connectionless, unreliable
       data transmission mechanism).
    o  SOCK_RAW - Provides access to internal network interfaces.
       Available only to users with either a system UIC or the SYSPRV
       privilege.
 protocol
    The protocol to be used with the socket. Normally, only a single
    protocol exists to support a particular socket type using a given
    address format. However, if many protocols exist, a particular
    protocol must be specified with this argument. Use the protocol
    number that is specific to the communication domain in which
    communication takes place.

  2 - Description

    This function provides the primary mechanism for creating
    sockets. The type and protocol of the socket affect the way the
    socket behaves and how it can be used.
    The operation of sockets is controlled by socket-level options,
    which are defined in the SOCKET.H header file and described in
    the setsockopt() function section of this chapter.
    Use the setsockopt() and getsockopt()  functions to set and
    get options. Options take an integer argument that should be
    nonzero if the option is to be enabled or zero if it is to be
    disabled. SO_LINGER uses a linger structure argument defined in
    <socket.h>.
    Related Functions
    See also accept(), bind(),  connect(), listen(), read(),  recv(),
    recvfrom(), recvmsg(),  select(), send(), sendmsg(),  sendto(),
    shutdown(), and write().
    Related Functions
    See also getsockname() and getsockopt().

  3 - Return Values

    x                  A file descriptor that refers to the socket
                       descriptor.
    -1                 Error; errno is set to indicate the error.

  4 - Errors

    EACCES             The process does not have sufficient
                       privileges.
    EAFNOSUPPORT       The specified address family is not supported
                       in this version of the system.
    EMFILE             The per-process descriptor table is full.
    ENETDOWN           TCP/IP Services was not started.
    ENFILE             No more file descriptors are available for the
                       system.
    ENOBUFS            The system has insufficient resources to
                       complete the call.
    ENOMEM             The system was unable to allocate kernel
                       memory to increase the process descriptor
                       table.
    EPERM              The process is attempting to open a raw socket
                       and does not have SYSTEM privilege.
    EPROTONOSUPPORT    The socket in the specified address family is
                       not supported.
    EPROTOTYPE         The socket type is not supported by the
                       protocol.
    ESOCKTNOSUPPORT    The specified socket type is not supported in
                       this address family.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.