Use the SENDTO command to send
an outgoing message on a socket descriptor. This command differs from
the SEND command in that it includes the destination address as a
parameter.
This command is used primarily to send data using connectionless
protocols such as UDP or RAW. Use the SENDTO command to send datagrams
on a UDP socket regardless of whether the socket is connected.
Guidelines: - For TCP or connected UDP sockets, use the SEND command.
- If the SO_ASCII socket option is enabled, then
the data received is translated from EBCDIC to ASCII.
Format
>>-SOCKET--(--"SENDTO"--,--socketid--,--data--,----------------->
>--+-----------+--,--name--)-----------------------------------><
'-sendflags-'
Parameters
- socketid
- The socket descriptor.
- data
- The data to be sent.
- sendflags
- Optional flags that specify how the data is sent. The following
flag is supported:
- MSG_DONTROUTE
- Do not route the data. Routing is handled by the calling program.
The DONTROUTE value is supported also.
- name
- The socket name of the remote host to which the data is sent.
The format for the
name parameter
depends on the socket type:
- AF_INET sockets (IPv4)
- name = "domain portid ipaddress"
- AF_INET6 sockets (IPv6)
- name = "domain portid flowinfo ipaddress scopeid"
where
- The domain value is the decimal number 2 for
AF_INET and the decimal number 19 for AF_INET6.
- The portid value is the port number.
- The ipaddress value is the IP address of the
remote host. It must be an IPv4 address for AF_INET and an IPv6 address
for AF_INET6.
- The flowinfo value must be 0.
- The scopeid value identifies
the interfaces that are applicable for the scope of the address that
is specified in the ipaddress field. For a link-local
IP address, the scopeid field can specify a link
index, which identifies a set of interfaces. For all other scopes,
the scopeid field must be set to 0. Setting the scopeid field
to 0 indicates that any address type and scope can be specified.
Returned value
The command returns a string that contains the return
code and an integer that specifies the amount of data that was sent,
for example, 0 192. The return code can be 0, a REXX socket API error number, or the REXX TCP/IP error number that is set by the socket command. The return code 0 indicates that the requested socket command was completed successfully.
See Socket call error return codes for additional information about the numeric error codes that are returned by this command.
The following REXX TCP/IP error numbers can be returned:- 4 EINTR
- 9 EBADF
- 5 EIO
- 22 EINVAL
- 32 EPIPE
- 35 EWOULDBLOCK
- 38 ENOTSOCK
- 40 EMSGSIZE45 EOPNOTSUPP
- 54 ECONNRESET
- 57 ENOTCONN
The following REXX socket API error numbers can be returned:- 2001 EINVALIDRXSOCKETCALL
- 2005 ESUBTASKNOTACTIVE
- 2009 ESOCKETNOTDEFINED
LE C/C++ equivalent
int sendto(int socket, char *buffer, int length, int flags, struct sockaddr
*address, int address_len);
Code example
See RECVFROM for an
example of using the SENDTO command.