Mikroc, Eth_load_tcp_header, Eth_send_udp – ABL electronic PIC Microcontrollers PIC16 User Manual
Page 190

mikroC - C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
182
MikroElektronika: Development tools - Books - Compilers
page
Prototype
void
Eth_Load_Tcp_Header(void);
Description
Loads various TCP Header data into PIC’s Ethernet variables.
Requires
This function must be called in a proper sequence, i.e. immediately after retrieving the
source and destination port (socket) of the TCP message.
Example
// retrieve 'source port'
tcp_source_port = Eth_Inport(NIC_DATA) << 8;
tcp_source_port |= Eth_Inport(NIC_DATA);
// retrieve 'destination port'
tcp_dest_port = Eth_Inport(NIC_DATA) << 8;
tcp_dest_port |= Eth_Inport(NIC_DATA);
// We only respond to port 80 (HTML requests)
if
(tcp_dest_port == 80u) {
Eth_Load_Tcp_Header();
// retrieve TCP Header data (most of it)
//...
}
Eth_Load_Tcp_Header
Prototype
void
Eth_Send_Udp(char *msg);
Description
Sends the prepared UDP message (
msg
), of up to 16 bytes (characters).
Unlike ICMP and TCP, the UDP packets are generally not generated as a response to the
client request. UDP provides no guarantees for message delivery and sender retains no
state on UDP messages once sent onto the network. This is why UDP packets are simply
sent, instead of being a response to someone’s request.
Requires
As specified for the entire library. Also, the message to be sent must be formatted as a
null-terminated string. The message length, including the trailing “0”, must not exceed
16 characters.
Example
Eth_Send_Udp(udp_tx_message);
Eth_Send_Udp