platform_net_socket.h 1.5 KB

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