unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

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



sendto(2)							    sendto(2)



NAME
  sendto - Sends messages through a socket

SYNOPSIS

  #include <&lt;sys/socket.h>&gt;
  ssize_t sendto (
	  int socket,
	  const	void *message,
	  size_t length,
	  int flags,
	  const	struct sockaddr	*dest_addr,
	  size_t dest_len);

  [POSIX]   The	definition of the sendto() function in POSIX.1g	Draft 6.6
  uses a socklen_t data	type for the dest_len parameter	instead	of a size_t
  data type as specified in XNS4.0 (the	previous definition).

  [Tru64 UNIX]	 The following definition of the sendto() function  does not
  conform to current standards and is supported	only for backward compatibil-
  ity (see standards(5)):

  #include <&lt;sys/socket.h>&gt;
  int sendto (
	  int socket,
	  char *message_addr,
	  int length,
	  int flags,
	  struct sockaddr *dest_addr,
	  int dest_len );

STANDARDS

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

  sendto():  XNS5.0

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

PARAMETERS

  socket    Specifies the file descriptor for the socket.

  message   Points to the address containing the message to be sent.

  length    Specifies the size of the message in bytes.

  flags	    Allows the sender to control the message transmission.  The	flags
	    value to send a call is formed by logically	ORing the following
	    values, defined in the sys/socket.h	file:

	    MSG_EOR   Terminates a record (if supported	by the protocol).

	    MSG_OOB   Processes	out-of-band data on sockets that support
		      out-of-band data.

	    MSG_DONTROUTE
		      [Tru64 UNIX]  Sends without using	routing	tables.	 (Not
		      recommended; for debugging purposes only.)

  dest_addr Points to a	sockaddr structure, the	format of which	is determined
	    by the domain and by the behavior requested	for the	socket.	 The
	    sockaddr structure is an overlay for a sockaddr_in,	sockaddr_un,
	    sockaddr_in6, or sockaddr_storage structure, depending on which
	    of the supported address families is active.

	    [Tru64 UNIX]   If the compile-time option _SOCKADDR_LEN is
	    defined before the sys/socket.h header file	is included, the
	    sockaddr structure takes 4.4BSD behavior, with a field for speci-
	    fying the length of	the socket address.  Otherwise,	the default
	    4.3BSD sockaddr structure is used, with the	length of the socket
	    address assumed to be 14 bytes or less.

	    If _SOCKADDR_LEN is	defined, the 4.3BSD sockaddr structure is
	    defined with the name osockaddr.

  dest_len  Specifies the length of the	sockaddr structure pointed to by the
	    dest_addr parameter.

DESCRIPTION

  The sendto() function	allows an application program to send messages
  through an unconnected socket	by specifying a	destination address.

  To broadcast on a socket, issue a setsockopt() function using	the
  SO_BROADCAST option to gain broadcast	permissions.

  Use the dest_addr parameter to provide the address of	the target.  Specify
  the length of	the message with the length parameter.

  If the sending socket	has no space to	hold the message to be transmitted,
  the sendto() function	blocks unless the socket is in a nonblocking I/O
  mode.

  Use the select() and poll() functions	to determine when to send more data.

RETURN VALUES

  Upon successful completion, the sendto() function returns the	number of
  characters sent.  Otherwise, a value of -1 is	returned, and errno is set to
  indicate the error.

ERRORS

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

  [EACCESS] Search permission is denied	for a component	of the path prefix;
	    or write access to the named socket	is denied.

  [EAFNOSUPPORT]
	    Addresses in the specified address family cannot be	used with
	    this socket.

  [EBADF]   The	socket parameter is not	valid.

  [ECONNRESET]
	    A connection was forcibly closed by	a peer.

  [EDESTADDRREQ]
	    You	did not	specify	a destination address for the connectionless
	    socket that	also did not have its peer address set.

  [EFAULT]  The	message	or dest_addr parameter is not in a writable part of
	    the	user address space.

  [EHOSTUNREACH]
	    The	destination host is not	reachable.

  [EINTR]   A signal interrupted sendto	before any data	was transmitted.

  [EINVAL]  The	dest_len parameter is not a valid size for the specified
	    address family.

  [EIO]	    For	an AF_UNIX socket, an I/O error	occurred while reading from
	    or writing to the file system.

  [EISCONN] The	connection-oriented socket for which a destination address
	    was	specified is already connected.

  [ELOOP]   For	an AF_UNIX socket, too many symbolic links were	encountered
	    in translating the pathname	in the socket address.

  [EMSGSIZE]
	    The	message	is too large to	be sent	all at once, as	the socket
	    requires.

  [ENAMETOOLONG]
	    For	an AF_UNIX socket, a component of the pathname exceeded
	    NAME_MAX characters, or an entire pathname exceeded	PATH_MAX
	    characters.

  [ENETDOWN]
	    The	local network connection is not	operational.

  [ENETUNREACH]
	    The	destination network is unreachable.

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

	    [Tru64 UNIX]  The interface	driver's send queue is full.  If the
	    problem persists, you might	increase the value for the ifqmaxlen
	    system attribute in	the net	subsystem.  See	sys_attrs_net(5) for
	    more information.

  [ENOENT]  For	an AF_UNIX socket, a component of the pathname does not	name
	    an existing	file or	the pathname is	an empty string.

  [ENOMEM]  The	system did not have sufficient memory to fulfill the request.

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

  [ENOTCONN]
	    The	socket is connection-oriented but is not connected.

  [ENOTDIR] For	an AF_UNIX socket, a component of the path prefix of the
	    pathname in	address	 is not	a directory.

  [ENOTSOCK]
	    The	socket parameter refers	to a file, not a socket.

  [EOPNOTSUPP]
	    The	socket argument	is associated with a socket that does not
	    support one	or more	of the values set in flags.

  [EPIPE]   The	socket is shut down for	writing, or the	socket is
	    connection-oriented	and the	peer is	closed or shut down for
	    reading. In	the latter case, and if	the socket is of type
	    SOCK_STREAM, the SIGPIPE signal is generated to the	calling	pro-
	    cess.

  [EWOULDBLOCK]
	    The	socket is marked nonblocking, and no space is available	for
	    the	sendto() function.

RELATED	INFORMATION

  Functions: getsockopt(2), poll(2), recv(2), recvfrom(2), recvmsg(2),
  select(2), send(2), sendmsg(2), setsockopt(2), shutdown(2), socket(2).

  Standards: standards(5).