Unique description of a bidirectional network communication channel. More...
#include <net.h>
Data Fields | |
uint32_t | error_code |
uint32_t | dest_addr |
uint16_t | dest_port |
uint16_t | ip_tos |
uint32_t | src_addr |
uint16_t | src_port |
uint16_t | res_align2 |
void * | user_pointer |
uint32_t | res_align3 [2] |
struct in_struct | in |
uint32_t | res [SO_SPARE] |
uint32_t | mc_dest_addr |
uint32_t | mc_group_addr |
uint16_t | mc_dest_port |
uint16_t | mc_src_port |
uint16_t | proto |
uint32_t | option |
uint32_t | status |
struct out_struct | out |
uint8_t | data_type |
uint8_t | data_shift |
Main structure to hold all information about a current connection (refer to Sockets). Each connection must have its own socket structure. Use socket_open() to acquire a new socket for a new connection. socket_open() returns a pointer to SOCKET, which is an abbreviation to socket_struct.
Not all socket_struct members are user accessible. Please make sure not to use res[SO_SPARE], which holds important internal information about the current connection (such as connection status, DNS sockets, timing and retransmit values, timeouts etc.). However it is possible to use res_align3[2] and *user_pointer as free scratch registers for application specific use.
The most important user accessible member is error_code. If a transmit function returns a SOCKET_ERROR the user should check the reason:
E.g. in a TCP callback function
uint32_t error_code |
uint32_t dest_addr |
socket destination address information
it can be used to determine destinations address after successful net_recv()
uint16_t dest_port |
socket destination port information
it can be used to determine destinations port after successful net_recv()
uint16_t ip_tos |
IP type of service
use immediately before net_send() or after net_recv()
uint32_t src_addr |
Local address
uint16_t src_port |
Local port
uint16_t res_align2 |
32 bit alignment.
user_pointer |
Free for custom use as a general purpose pointer
Useful to attach additional data to a specific socket
E.g. in example Echo.c:
uint32_t res_align3[2] |
128 bit alignment. Free for custom use as 32 bit scratch registers
struct in_struct in |
Data length of incoming packets
uint32_t res[SO_SPARE] |
Reserved data space, do not use
mc_dest_addr |
Multicast Destination address
mc_group_addr |
Multicast group address
mc_dest_port |
Multicast Destination port
mc_src_port |
Multicast Source port
uint32_t option |
uint32_t status |
struct out_struct out |
uint8_t data_type |
uint8_t data_shift |