W5500
socket.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
40 //
41 //*****************************************************************************
42 #ifndef _SOCKET_H_
43 #define _SOCKET_H_
44 
45 #include "wizchip_conf.h"
46 
47 #define SOCKOK_SUCC 0
48 #define SOCKERR_ERROR -1
49 #define SOCKERR_FATAL -1000
50 
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.
63 
64 #define SOCKFATAL_PACKLEN (SOCKERR_FATAL - 1) // Invalid packet length
65 
66 
67 int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
68 
69 int8_t close(uint8_t sn);
70 
71 int8_t listen(uint8_t sn);
72 
73 int8_t connect(uint8_t sn, uint8_t * addr, uint16_t port);
74 
75 int8_t disconnect(uint8_t sn);
76 
77 int32_t send(uint8_t sn, uint8_t * buf, uint16_t len);
78 
79 int32_t recv(uint8_t sn, uint8_t * buf, uint16_t len);
80 
81 int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port);
82 
83 int32_t recvfrom(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port);
84 
85 #endif // _SOCKET_H_