platform_net_socket.h 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-15 13:39:00
  5. * @LastEditTime: 2020-04-27 23:46:54
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #ifndef _PLATFORM_NET_SOCKET_H_
  9. #define _PLATFORM_NET_SOCKET_H_
  10. #include "network.h"
  11. #include "mqtt_error.h"
  12. #include "lwip/opt.h"
  13. #include "lwip/sys.h"
  14. #include "lwip/api.h"
  15. #include <lwip/sockets.h>
  16. #include "lwip/netdb.h"
  17. #define PLATFORM_NET_PROTO_TCP 0 /**< The TCP transport protocol */
  18. #define PLATFORM_NET_PROTO_UDP 1 /**< The UDP transport protocol */
  19. int platform_net_socket_connect(const char *host, const char *port, int proto);
  20. int platform_net_socket_recv(int fd, void *buf, size_t len, int flags);
  21. int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int timeout);
  22. int platform_net_socket_write(int fd, void *buf, size_t len);
  23. int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int timeout);
  24. int platform_net_socket_close(int fd);
  25. int platform_net_socket_set_block(int fd);
  26. int platform_net_socket_set_nonblock(int fd);
  27. int platform_net_socket_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen);
  28. #endif /* _PLATFORM_NET_SOCKET_H_ */