Switch to SpeakEasy.net DSL

The Modular Manual Browser

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

sendmsg(2)							   sendmsg(2)

  sendmsg - Sends a message from a socket using	a message structure


  #include <&lt;sys/socket.h>&gt;
  ssize_t sendmsg (
	  int socket,
	  const	struct msghdr *message,
	  int flags);

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

  int sendmsg (
	  int socket,
	  struct msghdr	*message,
	  int flags);


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

  sendmsg():  XNS5.0

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


  socket    Specifies the socket file descriptor.

  message   Points to a	msghdr structure, containing pointers to both the
	    destination	address	for the	outgoing message and to	buffers	con-
	    taining ancillary data.  The format	of the address is determined
	    by the behavior requested for the socket.

	    The	msghdr structure uses a	socklen_t data type for	the
	    msg_iovlen field instead of	a size_t data type as specified	in

	    [Tru64 UNIX]   If the compile-time option _SOCKADDR_LEN is
	    defined before the <sys/socket.h> header file is included, the
	    msghdr structure takes 4.4BSD behavior.  Otherwise,	the default
	    4.3BSD msghdr structure is used.

	    In 4.4BSD, the msghdr structure has	a separate msg_flags field
	    for	holding	flags from the received	message.  In addition, the
	    msg_accrights field	is generalized into a msg_control field.  See
	    the	recvmsg() function for more information.

	    If _SOCKADDR_LEN is	defined, the 4.3BSD msghdr structure is
	    defined with the name omsghdr.

  flags	    Allows the sender to control the message transmission.  The
	    <sys/socket.h> file	contains the flags values.  The	flags value
	    to send a call is formed by	a logical OR of	one or both of the
	    following values:

	    MSG_EOR	   Terminates a	record (if supported by	the proto-

	    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.)


  The sendmsg()	function sends messages	through	connected or unconnected
  sockets using	the msghdr message structure.  This minimizes the number of
  directly supplied parameters to the function call. The <sys/socket.h>	file
  contains the msghdr structure	and defines the	structure members.

  If the sending socket	has no space to	hold the message to be transmitted,
  sendmsg() waits until	space is available unless the socket is	in non-
  blocking I/O mode.

  To broadcast on a socket, the	application program must first issue a set-
  sockopt() function using the SO_BROADCAST option to gain broadcast permis-

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


  [Tru64 UNIX]	When compiled in the X/Open UNIX environment, calls to the
  sendmsg() function are internally renamed by prepending _E to	the function
  name.	When you are debugging a module	that includes the sendmsg() function
  and for which	_XOPEN_SOURCE_EXTENDED has been	defined, use _Esendmsg to
  refer	to the sendmsg() call.	See standards(5) for further information.

  [Tru64 UNIX]	When compiled in the POSIX.1g socket environment, calls	to
  the sendmsg()	function are internally	renamed	by prepending _P to the	func-
  tion name.  When you are debugging a module that includes the	sendmsg()
  function and for which _POSIX_PII_SOCKET has been defined, use _Psendmsg to
  refer	to the sendmsg() call.	See standards(5) for further information.


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


  If the sendmsg() function fails, errno may be	set to one of the following

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

  [EAFNOSUPPORT] You cannot use	addresses in the specified address family
		 with this socket.

  [EBADF]	 The socket parameter is not valid.

  [ECONNRESET]	 A peer	forcibly closed	a connection.

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

  [EFAULT]	 The message parameter;	storage	pointed	to by the msg_name,
		 msg_control, or msg_iov fields	of the message parameter; or
		 storage pointed to by the iovec structures pointed to by the
		 msg_iov field are not in a readable or	writable part of user

  [EHOSTUNREACH] The destination host is unreachable.  Possible	reasons
		 include the host is down or the router	has no route.

  [EINTR]	 A signal interrupted sendmsg before any data was transmit-

  [EINVAL]	 The sum of the	iov_len	values overflows an ssize_t.

  [EIO]		 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]	 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.

		 The value of the msg_iovlen member of the msghdr structure
		 is less than or equal to zero (0) or is greater than

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

  [ENETDOWN]	 The local network connection is not operational.

  [ENETUNREACH]	 The destination network is unreachable.

  [ENOBUFS]	 Insufficient resources	were available in the system to	com-
		 plete 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]	 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

  [ENOSR]	 The available STREAMS resources were insufficient for the
		 operation to complete.

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

  [ENOTDIR]	 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

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


  Functions: recv(2), recvfrom(2), recvmsg(2), send(2),	sendto(2), shut-
  down(2), socket(2), select(2), getsockopt(2),	setsockopt(2)

  Standards: standards(5)