The udp_get_socket function allocates a free UDP socket. The function initializes all the state variables of the UDP socket to the default state. The argument tos specifies the IP Type Of Service. The most common value for tos is 0. The argument opt specifies the checksum option as shown in the table. | Option Value | Description |
|---|
| UDP_OPT_SEND_CS | Calculate the UDP checksum for the packets to be sent. | | UDP_OPT_CHK_CS | Check the UDP checksum on the received packets. |
You can also set opt to UDP_OPT_SEND_CS|UDP_OPT_CHK_CS to enable both options. This is recommended for a more secure UDP connection. You can also disable both options by setting opt to 0 for fast system reaction time. The argument listener is the event listening function of the UDP socket. TCPnet calls the listener function whenever a UDP data packet is received. The arguments to the listener function are: - socket: UDP socket handle of the local machine.
- remip: pointer to the IP address of the remote machine.
- port: UDP port number on the remote machine.
- buf: pointer to buffer containing the received data.
- len: number of bytes in the received packet.
The udp_get_socket function is in the RL-TCPnet library. The prototype is defined in rtl.h. note - You must call the udp_get_socket function before any other function calls to the UDP socket.
- Ethernet packets are also protected by the ethernet CRC.
- Packets can be modified when passing through routers, proxy servers, gateways, etc.
- You must define the listener function to use with the UDP socket.
|