#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 ();
..
}
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.