Function for sending an UDP message to a specified station (nPort and nAddr).
|
i32 udp_send_to (i32 idx, buff, i32 dataLen, u32 rPort, u32 rIp)
|
|
Number of the handler of the UDP communication
|
|
Generic buffer containing the data packet to be transmitted. It can be a string variable, a struct_p (packed structure), or an array of struct_p. In the case of struct_p, the variable must be declared global
|
|
Number of total bytes to be transmitted
|
|
Number of the remote port to which the data is to be transmitted
|
|
IP address to which to transmit the data
|
|
Returns:
|
|
>= 0
|
Operation performed successfully. The number of characters sent is returned.
The message is always sent in full, so the number of bytes sent is always equal to dataLen unless there are errors
|
-1
|
Invalid port number
|
-2
|
Invalid address.
Must be different from 0
|
-3
|
Illegal idx
|
-4
|
Socket not open
|
-1000 -:- -2000
|
Error code of the S.O. function sendto(), with offset 1000
|
To see some returned errors more specifically, see Returned Error Table
|
|
Rule, Task
|
|
The function can be used for client and server communications
|
For a concrete example see in RDE environment: Workspace -> Specials -> Examples Library.
|
|
-1009
|
[EBADF] Id invalid
|
-1011
|
[EAGAIN or EWOULDBLOCK] Retry. The socket was non-blocking and receiving would block execution, or a timeout on receiving was imposed and that timeout expired before any data was received
|
-1013
|
[EACCES] The SO_BROADCAST option was not imposed on the socket and an address set is broadcast type
|
-1014
|
[EFAULT] Buffer pointer points to a memory area outside the process space
|
-1022
|
[EINVAL] The total I/O length is greater than the maximum that can be represented by the returned type
|
-1032
|
[EPIPE] The socket has lost its connection
|
-1088
|
[ENOTSOCK] Invalid id, does not refer to a socket
|
-1089
|
[EDESTADDRREQ] In an unconnected socket, the address was not specified
|
-1097
|
[EAFNOSUPPORT] The address specified in the address family cannot be used by this socket
|
-1105
|
[ENOBUFS] The message was not sent because it would have exceeded the maximum buffer size
|
-1106
|
[EISCONN] A destination address was specified and the socket is already connected
|
-1112
|
[EHOSTDOWN] The destination is a host on the local subnet and is not responding to the ARP protocol
|
-1113
|
[EHOSTUNREACH] Destination not reachable
|
-1122
|
[EMSGSIZE] Message too long
|
NOTE: For the complete table of error codes see Function error codes paying attention at the offset.
|