Manual Pages for UNIX Darwin command on man sendto
MyWebUniversity

Manual Pages for UNIX Darwin command on man sendto

SEND(2) BSD System Calls Manual SEND(2)

NAME

sseenndd, sseennddmmssgg, sseennddttoo - send a message from a socket

SYNOPSIS

##iinncclluuddee <>

ssizet sseenndd(int socket, const void *buffer, sizet length, int flags); ssizet sseennddmmssgg(int socket, const struct msghdr *buffer, int flags); ssizet sseennddttoo(int socket, const void *buffer, sizet length, int flags, const struct sockaddr *destaddr, socklent destlen);

DESCRIPTION

SSeenndd(), sseennddttoo(), and sseennddmmssgg() are used to transmit a message to another socket. SSeenndd() may be used only when the socket is in a connected state, while sseennddttoo() and sseennddmmssgg() may be used at any time. The address of the target is given by destaddr with destlen specifying its size. The length of the message is given by length. If the message is too long to pass atomically through the underlying protocol, the error EMSGSIZE is returned, and the message is not transmitted. No indication of failure to deliver is implicit in a sseenndd(). Locally

detected errors are indicated by a return value of -1.

If no messages space is available at the socket to hold the message to be transmitted, then sseenndd() normally blocks, unless the socket has been

placed in non-blocking I/O mode. The select(2) call may be used to

determine when it is possible to send more data. The flags parameter may include one or more of the following:

#define MSGOOB 0x1 /* process out-of-band data */

#define MSGDONTROUTE 0x4 /* bypass routing, use direct interface */

The flag MSGOOB is used to send ``out-of-band'' data on sockets that

support this notion (e.g. SOCKSTREAM); the underlying protocol must

also support ``out-of-band'' data. MSGDONTROUTE is usually used only by

diagnostic or routing programs. See recv(2) for a description of the msghdr structure.

RETURN VALUES

Upon successful completion, the number of bytes which were sent is

returned. Otherwise, -1 is returned and the global variable errno is set

to indicate the error. EERRRROORRSS The sseenndd(), sseennddmmssgg(), and sseennddttoo() system calls will fail if: [EACCES] The SOBROADCAST option is not set on the socket and a broadcast address is given as the destination.

[EAGAIN] The socket is marked non-blocking and the requested

operation would block. [EBADF] An invalid descriptor is specified. [ECONNRESET] A connection is forcibly closed by a peer. [EFAULT] An invalid user space address is specified for a parameter. [EHOSTUNREACH] The destination address specifies an unreachable host. [EINTR] A signal interrupts the system call before any data is transmitted. [EMSGSIZE] The socket requires that message be sent atomically, and the size of the message to be sent makes this impossible.

[ENETDOWN] The local network interface used to reach the destina-

tion is down. [ENETUNREACH] No route to the network is present. [ENOBUFS] The system is unable to allocate an internal buffer.

The operation may succeed when buffers become avail-

able. [ENOBUFS] The output queue for a network interface is full. This generally indicates that the interface has

stopped sending, but may be caused by transient con-

gestion. [ENOTSOCK] The argument socket is not a socket.

[EOPNOTSUPP] socket does not support (some of) the option(s) speci-

fied in flags. [EPIPE] The socket is shut down for writing or the socket is

connection-mode and is no longer connected. In the

latter case, and if the socket is of type SOCKSTREAM, the SIGPIPE signal is generated to the calling thread. The sseennddmmssgg() and sseennddttoo() system calls will fail if: [EAFNOSUPPORT] Addresses in the specified address family cannot be used with this socket.

[EDESTADDRREQ] The socket is not connection-mode and does not have

its peer address set, and no destination address is specified. [EISCONN] A destination address was specified and the socket is already connected. [ENOENT] A component of the pathname does not name an existing file or the path name is an empty string. [ENOMEM] Insufficient memory is available to fulfill the request.

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

[ENOTDIR] A component of the path prefix of the pathname in the socket address is not a directory. The sseenndd() system call will fail if:

[EDESTADDRREQ] The socket is not connection-mode and no peer address

is set. [ENOTCONN] The socket is not connected or otherwise has not had

the peer pre-specified.

The sseennddmmssgg() system call will fail if: [EINVAL] The sum of the iovlen values overflows an ssizet.

LEGACY SYNOPSIS

##iinncclluuddee <>

##iinncclluuddee <>

The include file is necessary.

SEE ALSO

fcntl(2), getsockopt(2), recv(2), select(2), socket(2), write(2), compat(5) HISTORY The sseenndd() function call appeared in 4.2BSD. 4.2 Berkeley Distribution February 21, 1994 4.2 Berkeley Distribution




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™