platform_net_socket.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-15 13:39:00
  5. * @LastEditTime: 2020-10-17 14:17:45
  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 <sys/types.h>
  11. #include <sys/socket.h>
  12. #include <sys/param.h>
  13. #include <sys/time.h>
  14. #include <sys/select.h>
  15. #include <netinet/in.h>
  16. #include <netinet/tcp.h>
  17. #include <arpa/inet.h>
  18. #include <netdb.h>
  19. #include <stdio.h>
  20. #include <unistd.h>
  21. #include <errno.h>
  22. #include <fcntl.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <signal.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #define PLATFORM_NET_PROTO_TCP 0 /**< The TCP transport protocol */
  30. #define PLATFORM_NET_PROTO_UDP 1 /**< The UDP transport protocol */
  31. int platform_net_socket_connect(const char *host, const char *port, int proto);
  32. int platform_net_socket_recv(int fd, void *buf, size_t len, int flags);
  33. int platform_net_socket_recv_timeout(int fd, unsigned char *buf, int len, int timeout);
  34. int platform_net_socket_write(int fd, void *buf, size_t len);
  35. int platform_net_socket_write_timeout(int fd, unsigned char *buf, int len, int timeout);
  36. int platform_net_socket_close(int fd);
  37. int platform_net_socket_set_block(int fd);
  38. int platform_net_socket_set_nonblock(int fd);
  39. int platform_net_socket_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* _PLATFORM_NET_SOCKET_H_ */