VMS Help
TCPIP Services, Programming Interfaces, Sockets API, sendto()

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

    Sends bytes through a socket to any other socket.
    The $QIO equivalent is the IO$_WRITEVBLK function.
    Format
      #include  <types.h>
      #include  <socket.h>
      int sendto  ( int s, char *msg, int len, int flags, struct
                  sockaddr *to, int tolen );

  1 - Arguments

 s
    A socket descriptor created with the socket() function.
 msg
    A pointer to a buffer containing the data to be sent.
 len
    The length of the data pointed to by the msg argument.
 flags
    Can be either 0 or MSG_OOB. If it is MSG_OOB, the data is sent
    out of band. Data can be received before other pending data on
    the receiving socket if the receiver specifies MSG_OOB in its
    flag argument of its recv(), recvfrom()  or recvmsg() call.
 to
    Points to the address structure of the socket to which the data
    is to be sent.
 tolen
    The length of the address pointed to by the to argument.

  2 - Description

    This function can be used on sockets to send data to named
    sockets. The data in the msg buffer is sent to the socket whose
    address is specified in the to argument, and the address of
    socket s is provided to the receiving socket. The receiving
    socket gets the data using the read(), recv(),  recvfrom(), or
    recvmsg() function.
    If there is no space available to buffer the data being sent
    on the receiving end of the connection, the sendto() function
    blocks until buffer space becomes available. If the socket is
    defined as nonblocking, the sendto() function fails with an errno
    indication of EWOULDBLOCK. If the message is too large to be sent
    in one piece and the socket type requires that messages be sent
    atomically (SOCK_DGRAM), the sendto() function fails with an
    errno indication of EMSGSIZE.
    No indication of failure to deliver is implicit in a sendto().
    All errors (except EWOULDBLOCK) are detected locally. You can use
    the select() function to determine when it is possible to send
    more data.
    If the address specified is a INADDR_BROADCAST address, then the
    SO_BROADCAST socket option must have been set and the process
    must have SYSPRV or BYPASS privilege for the I/O operation to
    succeed.
    Related Functions
    See also read(), recv(),  recvfrom(), recvmsg(), socket(),  and
    getsockopt().

  3 - Return Values

    n                  The number of bytes sent. This value normally
                       equals len.
    -1                 Error; errno is set to indicate the error.

  4 - Errors

    EAFNOSUPPORT       Addresses in the specified address family
                       cannot be used with this socket.
    EBADF              The socket descriptor is invalid.
    ECONNRESET         A connection was forcibly closed by a peer.
    EDESTADDRREQ       You did not specify a destination address for
                       the connectionless socket and no peer address
                       is set.
    EFAULT             An invalid user space address is specified for
                       a argument.
    EHOSTUNREACH       The destination host is unreachable.
    EINTR              A signal interrupted sendto() before any data
                       was transmitted.
    EINVAL             The dest_len argument is not a valid size for
                       the specified address family.
    EISCONN            The connection-oriented socket for which a
                       destination address was specified is already
                       connected.
    EMSGSIZE           The message is too large to be sent all at
                       once, as the socket requires.
    ENETDOWN           The local network connection is not
                       operational.
    ENETUNREACH        The destination network is unreachable.
    ENOBUFS            The system has insufficient to complete the
                       call.
    ENOMEM             The system did not have sufficient memory to
                       fulfill the request.
    ENOTCONN           The socket is connection-oriented but is not
                       connected.
    ENOTSOCK           The socket descriptor is invalid.
    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 is
                       connection oriented, and the peer is closed or
                       shut down for reading. In the latter case, if
                       the socket is of type SOCK_STREAM, the SIGPIPE
                       signal is generated to the calling process.
    EWOULDBLOCK        The socket is marked nonblocking, and no space
                       is available for the sendto() function.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.