hkcp.h 607 B

123456789101112131415161718192021222324252627282930
  1. #ifndef HV_KCP_H_
  2. #define HV_KCP_H_
  3. #include "hloop.h"
  4. #if WITH_KCP
  5. #include "ikcp.h"
  6. #include "hbuf.h"
  7. #define DEFAULT_KCP_UPDATE_INTERVAL 10 // ms
  8. #define DEFAULT_KCP_READ_BUFSIZE 1400
  9. typedef struct kcp_s {
  10. ikcpcb* ikcp;
  11. uint32_t conv;
  12. htimer_t* update_timer;
  13. hbuf_t readbuf;
  14. } kcp_t;
  15. // NOTE: kcp_create in hio_get_kcp
  16. void kcp_release(kcp_t* kcp);
  17. kcp_t* hio_get_kcp (hio_t* io, uint32_t conv);
  18. int hio_read_kcp (hio_t* io, void* buf, int readbytes);
  19. int hio_write_kcp(hio_t* io, const void* buf, size_t len);
  20. #endif
  21. #endif // HV_KCP_H_