cs_tcp.h 989 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * cs_tcp.h
  3. * Copyright (c) 2007-2018 ls
  4. **/
  5. #ifndef _CS_TCP_H_INCLUDED_
  6. #define _CS_TCP_H_INCLUDED_
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define CS_TCP_CONNECT_NONE 0x0
  11. #define CS_TCP_CONNECT_NONBLOCK 0x01
  12. #ifdef _WIN32
  13. CS_API int cs_tcp_init();
  14. CS_API void cs_tcp_cleanup();
  15. #endif
  16. CS_API cs_sock_t cs_tcp_v4_server(int port, char *bindaddr);
  17. CS_API cs_sock_t cs_tcp_v6_server(int port, char *bindaddr);
  18. CS_API cs_sock_t cs_tcp_accept(cs_sock_t s, u_char *ip, size_t ip_len, int *port);
  19. CS_API int cs_tcp_enable_nodelay(cs_sock_t fd);
  20. CS_API int cs_tcp_disable_nodelay(cs_sock_t fd);
  21. CS_API int cs_tcp_keepalive(cs_sock_t fd);
  22. CS_API int cs_tcp_sndtimeo(cs_sock_t fd, long long ms);
  23. CS_API int cs_tcp_rcvtimeo(cs_sock_t fd, long long ms);
  24. CS_API int cs_tcp_nonblocking(cs_sock_t fd);
  25. CS_API int cs_tcp_blocking(cs_sock_t fd);
  26. CS_API int cs_tcp_close(cs_sock_t fd);
  27. #ifdef __cplusplus
  28. }
  29. #endif /* C++ */
  30. #endif