Socket Error Codes | |
Socket Error Codes, read with socket_struct ->error_code
| |
#define | SO_NO_ERROR 0x00000000 /* no error */ |
#define | SO_TRANSMIT_ERROR 0x00000001 /* Transmit error */ |
#define | SO_NO_ARP_ADDRESS 0x00000002 /* Unresolved destination MAC */ |
#define | SO_TIMED_OUT 0x00000003 /* transfer function timed out */ |
#define | SO_IN_USE 0x00000004 /* TCP only: not ready */ |
#define | SO_NOT_ESTABLISHED 0x00000005 /* TCP only: not connected */ |
#define | SO_CONNECTION_RESET 0x00000006 /* TCP only: connection reset by remote host */ |
#define | SO_WRONG_CHECKSUM 0x00000007 /* net_recv():: data checksum failed */ |
#define | SO_BUFFER_TOO_SMALL 0x00000008 /* net_recv():: data > maxdatalen received */ |
#define | SO_NO_INPUT_BUFFER 0x00000009 /* net_recv():: NULL pointer given as data buffer */ |
#define | SO_NOT_OPEN 0x0000000a /* Socket is not open */ |
#define | SO_CONNECTION_CLOSED 0x0000000c /* TCP only: connection closed */ |
#define | SO_WINDOW_ERR 0x0000000d /* TCP only: window size zero received */ |
#define | SO_CONNECTION_ESTABLISHED 0x0000000e /* TCP only: connected */ |
#define | SO_MMU_ERROR 0x0000000f /* SMCS91c111: MMU error */ |
#define | SO_SEND_PENDING 0x00000010 /* Send pending */ |
#define | SO_NO_LINK 0x00000011 /* No valid link */ |
#define | SO_DNS_ERR 0x00000012 /* Name resolution missing or pending */ |
#define | SO_NO_TCP_MEM 0x00000013 /* TCP out of memory */ |
#define | SO_ERROR_MASK 0x7fffffff /* socket error mask */ |
Socket data and protocol types | |
Use with socket_open() | |
#define | DATATYPE_CHAR 0x1 |
#define | DATATYPE_SHORT 0x2 |
#define | DATATYPE_INT 0x4 |
#define | IPT_TCP |
#define | IPT_UDP |
#define | TCP_INIT_FUNC |
#define | UDP_INIT_FUNC |
#define | ICMP_INIT_FUNC |
Well known addresses | |
#define | ANY_ADDRESS "0.0.0.0" /* Any IP address */ |
#define | BROADCAST "255.255.255.255" /* Broadcast IP address */ |
Well known ports | |
#define | ANY_PORT 0 |
#define | ECHO_PORT 0x07 |
#define | TIME_SERVER_PORT 0x0D |
#define | FTP_DATA_PORT 0x14 |
#define | FTP_CONTROL_PORT 0x15 |
#define | TELNET_PORT 0x17 |
#define | DNS_SERVER_PORT 0x35 |
#define | DHCP_SERVER_PORT 0x43 |
#define | DHCP_CLIENT_PORT 0x44 |
#define | TFTP_SERVER_PORT 0x45 |
Socket Configuration Failure | |
socket_open() return value in case of insufficient memory or illegal configuration parameters | |
#define | INVALID_SOCKET NULL |
Socket Option | |
Use with set_socket_option() | |
#define | SO_UDP_NO_CHECKSUM 0x00000004 /* UDP w/o checksum */ |
#define | SO_TCP_STATE_CLOSED 0x00000008 /* use TCP state closed */ |
#define | SO_TCP_NO_RETRANS 0x00000020 /* disable TCP retransmit */ |
#define | SO_TCP_NO_FAST_RETRANS 0x00000040 /* disable fast TCP retransmit */ |
#define | SO_USE_PROXY 0x00000200 /* use proxy server */ |
Socket Failure | |
Socket Error, net_recv() and net_send() return code | |
#define | SOCKET_ERROR (_MAKE_32(-1)) |
Socket callback function return parameter | |
#define | SOCKET_CB_OK (_MAKE_32(1)) |
#define | SOCKET_CB_CLOSED (_MAKE_32(-1)) |
#define SO_NO_ERROR 0x00000000 /* no error */ |
#define SO_TRANSMIT_ERROR 0x00000001 /* Transmit error */ |
Socket Error Code
SO_TRANSMIT_ERROR is a TCP specific error. It may occur under the following conditions
#define SO_NO_ARP_ADDRESS 0x00000002 /* Unresolved destination MAC */ |
Socket Error Code
SO_NO_ARP_ADDRESS occurs when the address resolution failed. If this error is set, any following call to net_send() will fail and initiate a new ARP request.
Affected protocols: ICMP, UDP, TCP
#define SO_TIMED_OUT 0x00000003 /* transfer function timed out */ |
Callback function detects time-out due to 3 unanswered KEEP_ALIVE packets:
connect() returns SO_TIMED_OUT due to destination unreachable:
#define SO_IN_USE 0x00000004 /* TCP only: not ready */ |
#define SO_NOT_ESTABLISHED 0x00000005 /* TCP only: not connected */ |
Socket Error Code:
TCP only:
#define SO_CONNECTION_RESET 0x00000006 /* TCP only: connection reset by remote host */ |
Socket Error Code:
TCP only:
This error occurs any time a TCP_RST is received. The TCP state machine is reset and all data is flushed. Use a re-connect before sending new data.
#define SO_WRONG_CHECKSUM 0x00000007 /* net_recv():: data checksum failed */ |
Socket Error Code:
Affected protocols: ICMP, UDP and TCP
This error is set any time the checksum function determines a checksum error. Possibly data is overwritten by another task or by DMA. Ensure the data is not overwritten until it was processed.
In seldom cases this error was caused by a defective RAM chip.
#define SO_BUFFER_TOO_SMALL 0x00000008 /* net_recv():: data > maxdatalen received */ |
Socket Error Code:
Affected protocols: ICMP, UDP and TCP
Is set in net_isq() when a data packet is larger than the user defined buffer
#define SO_NO_INPUT_BUFFER 0x00000009 /* net_recv():: NULL pointer given as data buffer */ |
Socket Error Code:
Is set in net_isq() when the user defined buffer is equal to NULL. This usually happens, when no callback function was defined and the net_recv() task was blocked and never be executed while an incoming packet has to be written to a user buffer.
In this example the net_recv() function was accidentally commented out. Any incoming packet on this socket will cause the net_isq() to set the error code SO_NO_INPUT_BUFFER.
#define SO_NOT_OPEN 0x0000000a /* Socket is not open */ |
Socket Error Code:
net_recv() or net_send() return a SOCKET_ERROR SO_NOT_OPEN when the socket was previously closed. This may happen on operating systems when a receive task closes a socket while a transmit task processes a net_send().
#define SO_CONNECTION_CLOSED 0x0000000c /* TCP only: connection closed */ |
Socket Error Code:
TCP only:
This flag is set, when either the remote side or the user is shutting down the connection
#define SO_WINDOW_ERR 0x0000000d /* TCP only: window size zero received */ |
Socket Error Code:
Set in net_isq() or net_send() when
#define SO_CONNECTION_ESTABLISHED 0x0000000e /* TCP only: connected */ |
Socket Error Code:
TCP only: Set in net_isq() after successful three-way-handshake
#define SO_MMU_ERROR 0x0000000f /* SMCS91c111: MMU error */ |
Socket Error Code:
SMSC91C111 only: Possible race condition of SMSC91c111. If the SMSC91c111 allocation interrupt signals a free buffer and a buffer overrun interrupt occurs before the buffer is used, the buffer may be lost.
#define SO_SEND_PENDING 0x00000010 /* Send pending */ |
#define SO_NO_LINK 0x00000011 /* No valid link */ |
Socket Error Code:
Is set, when the link is broken during transmit.
#define SO_DNS_ERR 0x00000012 /* Name resolution missing or pending */ |
Socket Error Code:
TCP only: Name resolution missing or pending.
If the destination host name was specified and not a certain IP address, the TCP/IP stack tries to resolve the address during connect(). If the address resolution failed, error code SO_DNS_ERR is set.
#define SO_NO_TCP_MEM 0x00000013 /* TCP out of memory */ |
Socket Error Code:
TCP out of memory
No net_isq() is handled in the example above. Any time net_send() is called new TCP sequence numbers are occupied and due to the missing net_isq() call never be freed. The TCP sequence number memory will run full and the error code SO_NO_TCP_MEM will be set.
#define SO_ERROR_MASK 0x7fffffff /* socket error mask */ |
#define DATATYPE_CHAR 0x1 |
socket_open() Parameter: Data type character
#define DATATYPE_SHORT 0x2 |
socket_open() Parameter: Data type short
#define DATATYPE_INT 0x4 |
socket_open() Parameter: Data type int
#define IPT_TCP |
socket_open() Parameter: Protocol type TCP
#define IPT_UDP |
socket_open() Parameter: Protocol type UDP
#define TCP_INIT_FUNC |
socket_open() Parameter: TCP initialization handler
#define UDP_INIT_FUNC |
socket_open() Parameter: UDP initialization handler
#define ICMP_INIT_FUNC |
socket_open() Parameter: ICMP initialization handler
#define ANY_ADDRESS "0.0.0.0" /* Any IP address */ |
socket_open() Parameter:
This socket accepts connections from any IP
#define BROADCAST "255.255.255.255" /* Broadcast IP address */ |
socket_open() Parameter:
Broadcast IP address
#define ANY_PORT 0 |
socket_open() Parameter
Used for servers
#define ECHO_PORT 0x07 |
#define TIME_SERVER_PORT 0x0D |
socket_open() Parameter
Time server port
#define FTP_DATA_PORT 0x14 |
FTP data port
#define FTP_CONTROL_PORT 0x15 |
FTP control port
#define TELNET_PORT 0x17 |
socket_open() Parameter
FTP telnet port
#define DNS_SERVER_PORT 0x35 |
socket_open() Parameter
DNS server port
#define DHCP_SERVER_PORT 0x43 |
socket_open() Parameter
DHCP server port
#define DHCP_CLIENT_PORT 0x44 |
socket_open() Parameter
DHCP client port
#define TFTP_SERVER_PORT 0x45 |
socket_open() Parameter
TFTP server port
#define INVALID_SOCKET NULL |
Use INVLAID_SOCKET to test socket_open() function for failure.
#define SO_UDP_NO_CHECKSUM 0x00000004 /* UDP w/o checksum */ |
set_socket_option() Parameter:
Use this parameter to switch off and ignore the UDP checksum. Useful, to accelerate processing speed.
#define SO_TCP_STATE_CLOSED 0x00000008 /* use TCP state closed */ |
set_socket_option() Parameter:
The default TCP state of opened sockets in the D.SignT TCP/IP stack is the listening state (TCP_LISTEN). In some cases (e.g. for a concurrent HTTP web server) this leads to connection problems. A shortly closed TCP socket may be wrongly established again immediately. To prevent this behaviour use this socket option. This adds two additional TCP states (TCP_CLOSED and TCPS_FIN_WAIT_2) to the TCP state machine. Function tcp_listen() is used to switch the socket state from TCP_CLOSED to TCP_LISTEN. After shutting down a connection the TCP state is TCPS_FIN_WAIT_2 for a certain time and then again TCP_CLOSED.
#define SO_TCP_NO_RETRANS 0x00000020 /* disable TCP retransmit */ |
set_socket_option() Parameter:
Disable TCP retransmits.
#define SO_TCP_NO_FAST_RETRANS 0x00000040 /* disable fast TCP retransmit */ |
set_socket_option() Parameter:
When the remote side is configured for delayed ACK, a single TCP packet may take a long time to be acknowledged. To force a fast acknowledge, the D.SignT TCP/IP Stack uses "fast retransmits" as default. Use SO_TCP_NO_FAST_RETRANS to disable this behaviour.
#define SO_USE_PROXY 0x00000200 /* use proxy server */ |
set_socket_option() Parameter:
The gateway configured with net_set_gateway() is used as proxy-server.
#define SOCKET_ERROR (_MAKE_32(-1)) |
#define SOCKET_CB_OK (_MAKE_32(1)) |
normal return code
#define SOCKET_CB_CLOSED (_MAKE_32(-1)) |
return code, if socket was closed