#include <rtl.h>
BOOL udp_open (
U8 socket, /* Socket handle to use for communication. */
U16 locport); /* Local port to use for communication. */
Description
The udp_open function opens the UDP socket identified by
the argument socket for communication. The argument
locport specifies the local port that is to be used to send
and receive data packets.
The udp_open function is in the RL-TCPnet library. The
prototype is defined in rtl.h.
Note
If you specify 0 for locport, TCPnet automatically
allocates the first free UDP port for communication.
Return Value
The udp_open function returns __TRUE if the socket is
opened successfully. Otherwise, the function returns __FALSE.
#include <rtl.h>
U8 udp_soc;
U16 udp_callback (U8 socket, U8 *remip, U16 remport, U8 *buf, U16 len) {
/* This function is called when UDP data is received */
/* Process received data from 'buf' */
..
return (0);
}
void main (void) {
init ();
/* Initialize the TcpNet */
init_TcpNet ();
udp_soc = udp_get_socket (0, UDP_OPT_SEND_CS | UDP_OPT_CHK_CS, udp_callback);
if (udp_soc != 0) {
/* Open UDP port 1000 for communication */
udp_open (udp_soc, 1000);
}
while (1);
/* Run main TcpNet 'thread' */
main_TcpNet ();
..
}
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.