*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> socket (2)              
Title
Content
Arch
Section
 

s(4)

Contents


 socket(2)                                                         socket(2)




 NAME    [Toc]    [Back]
      socket() - create an endpoint for communication

 SYNOPSIS    [Toc]    [Back]
      #include <sys/socket.h>

    AF_CCITT Only    [Toc]    [Back]
      #include <x25/x25ccittproto.h>

      int socket(int af, int type, int protocol);

 DESCRIPTION    [Toc]    [Back]
      The socket() system call creates an endpoint for communication and
      returns a descriptor.  The socket descriptor returned is used in all
      subsequent socket-related system calls.

      The af parameter specifies an address family to be used to interpret
      addresses in later operations that specify the socket.  These address
      families are defined in the include files <sys/socket.h> and
      <x25/ccittproto.h>.  The only currently supported address families
      are:

           AF_INET             (DARPA Internet addresses)
           AF_INET6            (Internet Protocol version 6)
           AF_UNIX             (path names on a local node)
           AF_CCITT            (CCITT X.25 addresses)
           AF_VME_LINK         (backplane communications on VMEbus)

      The type specifies the semantics of communication for the socket.
      Currently defined types are:

           SOCK_STREAM         Sequenced, reliable, two-way-connection-based
                               byte streams.

           SOCK_DGRAM          Datagrams (connectionless, unreliable
                               messages of a fixed, typically small, maximum
                               length; for AF_INET only).

      protocol specifies a particular protocol to be used with the socket.
      Normally, only a single protocol exists to support a particular socket
      type using a given address family.  However, many protocols may exist,
      in which case a particular protocol must be specified.  The protocol
      number to use depends on the communication domain in which
      communication is to take place (see service
).
      protocol can be specified as zero, which causes the system to choose a
      protocol type to use.

      Sockets of type SOCK_STREAM are byte streams similar to pipes, except
      that they are full-duplex instead of half-duplex.  A stream socket
      must be in a connected state before any data can be sent or received
      on it.  A connection to another socket is created with a connect() or



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 socket(2)                                                         socket(2)




      accept() call.  Once connected, data can be transferred using some
      variant of the send() and recv() or the read() and write() calls.
      When a session is complete, use close() or shutdown() calls to
      terminate the connection.

      TCP, the communications protocol used to implement SOCK_STREAM for
      AF_INET or AF_INET6 sockets, ensures that data is not lost or
      duplicated.  If a peer has buffer space for data and the data cannot
      be successfully transmitted within a reasonable length of time, the
      connection is considered broken and the next recv() call indicates an
      error with errno set to [ETIMEDOUT].  If SO_KEEPALIVE is set and the
      connection has been idle for two hours, the TCP protocol sends
      "keepalive" packets every 75 seconds to determine whether the
      connection is active.  These transmissions are not visible to users
      and cannot be read by a recv() call.  If the remote system does not
      respond within 10 minutes (i.e., after 8 "keepalive" packets have been
      sent), the next socket call (e.g., recv()) returns an error with errno
      set to [ETIMEDOUT].  A SIGPIPE signal is raised if a process sends on
      a broken stream.  This causes naive processes that do not handle the
      signal to exit.  An end-of-file condition (zero bytes read) is
      returned if a process tries to read on a broken stream.

      SOCK_DGRAM sockets allow sending of messages to correspondents named
      in send() calls.  It is also possible to receive messages at such a
      socket with recv().

      The operation of sockets is controlled by socket level options set by
      the setsockopt() system call described by the getsockopt(2) manual
      entry.  These options are defined in the file <sys/socket.h> and
      explained in the getsockopt(2) manual entry.

    X.25 Only    [Toc]    [Back]
      Socket endpoints for communication over an X.25/9000 link can be in
      either address family, AF_INET or AF_CCITT.  If the socket is in the
      AF_INET family, the connection behaves as described above.  TCP is
      used if the socket type is SOCK_STREAM.  UDP is used if the socket
      type is SOCK_DGRAM.  In both cases, Internet protocol (IP) and the
      X.25-to-IP interface module are used.

      If the socket is in the AF_CCITT address family, only the SOCK_STREAM
      socket type is supported.  Refer to the topic "Comparing X.25 Level 3
      Access to IP" in the X.25 Programmer's Guide for more details on the
      difference between programmatic access to X.25 via IP and X.25 Level
      3.

      If the socket is in the AF_CCITT family, the connection and all other
      operations pass data directly from the application to the X.25 Packet
      Level (level 3) without passing through a TCP or UDP protocol.
      Connections of the AF_CCITT family cannot use most of the socket level
      options described in getsockopt(2).  However, AF_CCITT connections can
      use many X.25-specific ioctl() calls.



 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003






 socket(2)                                                         socket(2)




 DEPENDENCIES    [Toc]    [Back]
    AF_CCITT and AF_VME_LINK
      Only the SOCK_STREAM type is supported.

 RETURN VALUE    [Toc]    [Back]
      socket() returns the following values:

            n   Successful completion.  n is a valid file descriptor
                referring to the socket.
           -1   Failure.  errno is set to indicate the error.

 ERRORS    [Toc]    [Back]
      If socket() fails, errno is set to one of the following values.

           [EAFNOSUPPORT]           The specified address family is not
                                    supported in this version of the system.

           [EHOSTDOWN]              The networking subsystem is not up.

           [EINVAL]                 SOCK_DGRAM sockets are currently not
                                    supported for the AF_UNIX or AF_VME_LINK
                                    address families.

           [EMFILE]                 The per-process descriptor table is
                                    full.

           [ENFILE]                 The system's table of open files is
                                    temporarily full and no more socket()
                                    calls can be accepted.

           [ENOBUFS]                No buffer space is available.  The
                                    socket cannot be created.

           [ENOMEM]                 No memory is available.  The socket
                                    cannot be created.

           [EPROTONOSUPPORT]        The specified protocol is not supported.

           [EPROTOTYPE]             The type of socket and protocol do not
                                    match.

           [ESOCKTNOSUPPORT]        The specified socket type is not
                                    supported in this address family.

           [ETIMEDOUT]              Connection timed out.

 WARNINGS    [Toc]    [Back]
      Not all possible errno values are documented in each socket related
      manpage due to dependencies from the underlying protocol modules.
      Refer to the errno(2) manpage for a complete list of error codes.




 Hewlett-Packard Company            - 3 -   HP-UX 11i Version 2: August 2003






 socket(2)                                                         socket(2)




      IPv6 is supported on HP-UX 11i Version 1.0, with the optional IPv6
      software installed.  Currently, IPv6 is not supported on systems
      running HP-UX 11i Version 1.6.

 FUTURE DIRECTION    [Toc]    [Back]
      Currently, the default behavior is the HP-UX BSD Sockets; however, it
      might be changed to X/Open Sockets in a future release.  At that time,
      any HP-UX BSD Sockets behavior that is incompatible with X/Open
      Sockets might be obsoleted.  Applications that conform to the X/Open
      specification now will avoid migration problems (see
      xopen_networking(7)).

 AUTHOR    [Toc]    [Back]
      socket() was developed by HP and the University of California,
      Berkeley.

 SEE ALSO    [Toc]    [Back]
      accept(2), bind(2), connect(2), getsockname(2), getsockopt(2),
      ioctl(2), listen(2), recv(2), select(2), send(2), shutdown(2),
      thread_safety(5), socket(7), tcp(7P), udp(7P), unix(7P),
      xopen_networking(7).

 STANDARDS CONFORMANCE    [Toc]    [Back]
      socket(): XPG4


 Hewlett-Packard Company            - 4 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
ttdt_open HP-UX create a ToolTalk communication endpoint
ttdt_close HP-UX destroy a ToolTalk communication endpoint
pipe OpenBSD create descriptor pair for interprocess communication
socket Tru64 Create an end point for communication and return a descriptor
pipe NetBSD create descriptor pair for interprocess communication
pipe FreeBSD create descriptor pair for interprocess communication
dcecp_endpoint HP-UX A dcecp object that manages endpoint information in local RPC endpoint maps
t6get_endpt_mask IRIX get or set endpoint security attribute mask, get or set endpoint default security attributes
t_close IRIX close a transport endpoint
t_close Tru64 Close a transport endpoint.
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service