platform_net_socket.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-15 13:39:00
  5. * @LastEditTime: 2020-06-18 20:12:15
  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. #ifdef MQTT_NETSOCKET_USING_AT
  13. #include "sal_module_wrapper.h"
  14. #else
  15. #include "lwip/opt.h"
  16. #include "lwip/sys.h"
  17. #include "lwip/api.h"
  18. #include <lwip/sockets.h>
  19. #include "lwip/netdb.h"
  20. #endif
  21. #define PLATFORM_NET_PROTO_TCP 0 /**< The TCP transport protocol */
  22. #define PLATFORM_NET_PROTO_UDP 1 /**< The UDP transport protocol */
  23. int platform_net_socket_connect(const char *host, const char *port, int proto);
  24. int platform_net_socket_recv(int fd, void *buf, size_t len, int flags);
  25. int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int timeout);
  26. int platform_net_socket_write(int fd, void *buf, size_t len);
  27. int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int timeout);
  28. int platform_net_socket_close(int fd);
  29. #ifndef MQTT_NETSOCKET_USING_AT
  30. int platform_net_socket_set_block(int fd);
  31. int platform_net_socket_set_nonblock(int fd);
  32. int platform_net_socket_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen);
  33. #endif
  34. #endif /* _PLATFORM_NET_SOCKET_H_ */