48 #define SOCKERR_ERROR -1
49 #define SOCKERR_FATAL -1000
51 #define SOCKERR_SOCKNUM (SOCKERR_ERROR - 1) // Invalid socket number
52 #define SOCKERR_SOCKOPT (SOCKERR_ERROR - 2) // Invalid socket option
53 #define SOCKERR_SOCKINIT (SOCKERR_ERROR - 3) // Socket is not initialized
54 #define SOCKERR_SOCKCLOSED (SOCKERR_ERROR - 4) // Socket unexpectly closed.
55 #define SOCKERR_SOCKMODE (SOCKERR_ERROR - 5) // Invalid socket mode for socket operation.
56 #define SOCKERR_SOCKSTATUS (SOCKERR_ERROR - 6) // Invalid socket status for socket operation.
57 #define SOCKERR_PORTZERO (SOCKERR_ERROR - 10) // Port number is zero
58 #define SOCKERR_IPINVALID (SOCKERR_ERROR - 11) // Invalid IP address
59 #define SOCKERR_TIMEOUT (SOCKERR_ERROR - 12) // Timeout occurred
60 #define SOCKERR_DATALEN (SOCKERR_ERROR - 13) // Data length is zero or greater than buffer max size.
61 #define SOCKERR_BUFFER (SOCKERR_ERROR - 14) // Socket buffer is not enough for data communication.
62 #define SOCKERR_BUSY (SOCKERR_ERROR - 20) // Socket is busy on processing the operation.
64 #define SOCKFATAL_PACKLEN (SOCKERR_FATAL - 1) // Invalid packet length
67 int8_t
socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
69 int8_t
close(uint8_t sn);
73 int8_t
connect(uint8_t sn, uint8_t * addr, uint16_t port);
77 int32_t
send(uint8_t sn, uint8_t * buf, uint16_t len);
79 int32_t
recv(uint8_t sn, uint8_t * buf, uint16_t len);
81 int32_t
sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);
83 int32_t
recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port);