platform_net_socket.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2020-01-10 23:45:59
  5. * @LastEditTime : 2020-01-13 02:48:53
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #include "platform_net_socket.h"
  9. int platform_net_socket_connect(const char *host, const char *port, int proto)
  10. {
  11. int fd;
  12. fd = tos_sal_module_connect(host, port, TOS_SAL_PROTO_TCP);
  13. if (fd < 0) {
  14. return MQTT_CONNECT_FAILED_ERROR;
  15. }
  16. return fd;
  17. }
  18. int platform_net_socket_recv(int fd, void *buf, size_t len, int flags)
  19. {
  20. return tos_sal_module_recv(fd, buf, len);
  21. }
  22. int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int timeout)
  23. {
  24. return tos_sal_module_recv_timeout(fd, buf, len, timeout);
  25. }
  26. int platform_net_socket_write(int fd, void *buf, size_t len)
  27. {
  28. return tos_sal_module_send(fd, buf, len);
  29. }
  30. int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int timeout)
  31. {
  32. return tos_sal_module_send(fd, buf, len);
  33. }
  34. int platform_net_socket_close(int fd)
  35. {
  36. return tos_sal_module_close(fd);
  37. }