PikaPlatform_socket.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "PikaObj.h"
  2. #ifdef __linux__
  3. #include <arpa/inet.h>
  4. #include <errno.h>
  5. #include <fcntl.h>
  6. #include <netdb.h>
  7. #include <sys/socket.h>
  8. #include <unistd.h>
  9. #elif PIKA_LWIP_ENABLE
  10. #include <lwip/sockets.h>
  11. #include "lwip/api.h"
  12. #include "lwip/netdb.h"
  13. #include "lwip/opt.h"
  14. #include "lwip/sys.h"
  15. #else
  16. /*
  17. You need to create the __platform_socket.h for your platform.
  18. For example:
  19. You can #include "lwip/socket.h" in the __platform_socket.h
  20. */
  21. #include "__platform_socket.h"
  22. #endif
  23. int __platform_socket(int __domain, int __type, int __protocol);
  24. int __platform_bind(int __fd,
  25. const struct sockaddr* __addr,
  26. socklen_t __addr_len);
  27. int __platform_listen(int __fd, int __n);
  28. int __platform_accept(int __fd, struct sockaddr* __addr, socklen_t* __addr_len);
  29. int __platform_connect(int __fd,
  30. const struct sockaddr* __addr,
  31. socklen_t __addr_len);
  32. int __platform_send(int __fd, const void* __buf, size_t __n, int __flags);
  33. int __platform_recv(int __fd, void* __buf, size_t __n, int __flags);
  34. int __platform_gethostname(char* __name, size_t __len);
  35. int __platform_getaddrinfo(const char* __name,
  36. const char* __service,
  37. const struct addrinfo* __req,
  38. struct addrinfo** __pai);
  39. void __platform_freeaddrinfo(struct addrinfo* __ai);
  40. int __platform_setsockopt(int __fd,
  41. int __level,
  42. int __optname,
  43. const void* __optval,
  44. socklen_t __optlen);
  45. /* os file API */
  46. int __platform_close(int fd);
  47. int __platform_write(int fd, const void* buf, size_t count);
  48. int __platform_fcntl(int fd, int cmd, long arg);