unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (OSF1-V5.1-alpha)
Page:
Section:
Apropos / Subsearch:
optional field



socket(2)							    socket(2)



NAME
  socket - Creates an end point	for communication and returns a	descriptor

SYNOPSIS

  #include <&lt;sys/socket.h>&gt;
  int socket  (
	  int domain,
	  int type,
	  int protocol );

STANDARDS

  Interfaces documented	on this	reference page conform to industry standards
  as follows:

  socket():  XNS5.0

  Refer	to the standards(5) reference page for more information	about indus-
  try standards	and associated tags.

PARAMETERS

  domain    Specifies the communications domain	in which a socket is to	be
	    created.  The domain argument specifies the	address	family with
	    which addresses specified in later socket operations should	be
	    interpreted.  The sys/socket.h file	contains the definitions of
	    the	address	families.  Commonly used families are:

	    AF_UNIX   UNIX pathnames

	    AF_INET   Internet addresses (IPv4)

	    AF_INET6  [Tru64 UNIX]   Internet addresses	(IPv6)

  type	    Specifies the semantics of communication. The sys/socket.h file
	    defines the	socket types.  The following types are supported:

	    SOCK_STREAM
		      Provides sequenced, reliable, two-way byte streams with
		      a	transmission mechanism for out-of-band data.

	    SOCK_DGRAM
		      Provides datagrams, which	are connectionless messages
		      of a fixed maximum length.

	    SOCK_RAW  [Tru64 UNIX]   Provides access to	internal network pro-
		      tocols and interfaces. This type of socket is available
		      only to a	process	with superuser privilege.

  protocol  Specifies a	particular protocol to be used with the	socket.
	    Specifying a protocol of 0 (zero) causes the socket() function to
	    default to the typical protocol for	the requested type of
	    returned socket.

DESCRIPTION

  The socket() function	creates	a socket of the	specified type in the speci-
  fied domain.

  The socket() function	returns	a descriptor (an integer) that can be used in
  later	system calls that operate on sockets.

  Socket level options control socket operations. The getsockopt() and set-
  sockopt() functions are used to get and set these options, which are
  defined in the sys/socket.h file.

RETURN VALUES

  Upon successful completion, the socket() function returns a nonnegative
  integer (the socket descriptor).  Otherwise, a value of -1 is	returned and
  errno	is set to indicate the error.

ERRORS

  If the socket() function fails, errno	may be set to one of the following
  values:

  [EACCES]  The	process	have not have appropriate privileges.

  [EAFNOSUPPORT]
	    The	addresses in the specified address family are not available
	    in the kernel.

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

  [ENFILE]  No more file descriptors are available for the system.

  [ENOBUFS] Insufficient resources were	available in the system	to complete
	    the	call.

  [ENOMEM]  The	system was unable to allocate kernel memory to increase	the
	    process descriptor table.

  [ENOSR]   The	available STREAMS resources were insufficient for the opera-
	    tion to complete.

  [EPERM]   [Tru64 UNIX]  The process is attempting to open a raw socket and
	    does not have superuser privilege.

  [EPROTONOSUPPORT]
	    The	socket in the specified	address	family is not supported.

  [EPROTOTYPE]
	    The	socket type is not supported by	the protocol.

RELATED	INFORMATION

  Functions: accept(2),	bind(2), connect(2), listen(2),	getsockname(2),	get-
  sockopt(2), recv(2), recvfrom(2), recvmsg(2),	send(2), sendto(2),
  sendmsg(2), setsockopt(2), shutdown(2), socketpair(2)

  Standards: standards(5)