Functions | |
int16_t | send_ip (SOCKET *so, addr_type *dest, uint16_t len, uint16_t id) |
Low-level send function for sending RAW IP packets. More... | |
int32_t | net_send (SOCKET *so, void *data, uint16_t len) |
Send a message via the specified socket. More... | |
int32_t | net_send_string (SOCKET *so, char *data) |
Send a zero terminated string via the specified socket. More... | |
int32_t | net_send_ready (SOCKET *so, void *data, uint32_t len, uint32_t timeout) |
Send a message via the specified socket, wait until message is successfully transmitted or a timeout occurred. More... | |
int32_t | net_recv (SOCKET *so, void *data, uint16_t maxdatasize) |
Receive data via the specified socket. More... | |
int32_t | set_recv_buffer (SOCKET *so, void *data, uint16_t maxdatasize) |
Define a socket buffer. More... | |
int32_t | net_recv_ready (SOCKET *so, void *data, int32_t *len, uint32_t timeout) |
Receive data via the specified socket, wait until message is successfully received and connection closed from sender or a timeout occurred. More... | |
so | - socket to use |
dest | - destination address information |
len | - length of data to be transmitted |
id | - unique packet id |
This function is used to send RAW IP packets. Address resolution and checksum generation must be performed manually.
so | - pointer to socket |
data | - pointer to data, data type as specified in socket_open() |
len | - length of data |
Transmit function for sending UDP or TCP packets. All protocol specific information are generated automatically. net_send() is a non-blocking function. In case of an unknown address (no or invalid ARP cache entry) net_send() starts the address resolution and returns immediately. The data pointer (void *data) is passed to the protocol stack for later transmission. After successful address resolution the stack maintenance function net_isq() will transmit this packet.
int32_t net_send_string | ( | SOCKET * | so, |
char * | data | ||
) |
The string can be longer than the maximum packet size. In this case it's broken into several packets by net_send_ready(). This is a blocking function. a return value true does NOT guarantee successful transmission
so | - pointer to socket |
data | - pointer to zero terminated data, data type as specified in socket_open() |
so | - pointer to socket |
data | - pointer to the data, data type as specified in socket_open() |
len | - length of data |
timeout | - timeout for transmission = number of re-tries |
Send a message via the specified socket, wait until message is successfully transmitted or a time out occurred.
so | - pointer to socket |
data | - pointer to receive buffer |
maxdatasize | - maximum allowed length |
This function returns the number of previously received bytes or in case of errors/events NET_RECV_EVENT (-1). For TCP a connection status change (SO_CONNECTION_RESET, SO_CONNECTION_CLOSED and SO_CONNECTION_ESTABLISHED) is also signalled with NET_RECV_EVENT. If no callback function (socket_define_callback) is installed for this socket, these events have to be cleared by the user to avoid further event/error checking. A special case exists for a TCP socket being closed (SO_CONNECTION_RESET or SO_CONNECTION_CLOSED) while data is received. The connection status change event may cover a final received data packet. Check socket_struct -> in. data_len to determine if data was received with the last packet.
Examples:
Example using the Support Function Framework
so | - pointer to socket |
data | - pointer to receive buffer |
maxdatasize | - maximum allowed length |
Due to the zero-copy functionality net_isq() transfers all data to a user defined buffer. To initialize this buffer use set_recv_buffer().
so | - pointer to socket |
data | - pointer to receive buffer |
len | - pointer to maximum receive length, returns received data length |
timeout | - timeout for receive = number of loop count |