Handle.hx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package eval.luv;
  2. @:coreType abstract SocketHandle {}
  3. /**
  4. Handles.
  5. @see https://aantron.github.io/luv/luv/Luv/Handle
  6. **/
  7. @:coreType abstract Handle {
  8. /**
  9. Closes the given handle.
  10. **/
  11. extern static public function close(handle:Handle, callback:()->Void):Void;
  12. /**
  13. Returns `true` if the handle is active, `false` otherwise.
  14. **/
  15. static public function isActive(handle:Handle):Bool;
  16. /**
  17. Returns `true` if the handle is closing or closed, `false` otherwise.
  18. Note: This function should only be used between the initialization of
  19. the handle and the arrival of the close callback.
  20. **/
  21. static public function isClosing(handle:Handle):Bool;
  22. /**
  23. Reference the given handle.
  24. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-ref
  25. **/
  26. static public function ref(handle:Handle):Void;
  27. /**
  28. Un-reference the given handle.
  29. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-unref
  30. **/
  31. static public function unref(handle:Handle):Void;
  32. /**
  33. Returns `true` if the handle referenced, `false` otherwise.
  34. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-has_ref
  35. **/
  36. static public function hasRef(handle:Handle):Bool;
  37. /**
  38. Gets the size of the OS send buffer for a socket.
  39. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-send_buffer_size
  40. **/
  41. static public function sendBufferSize(handle:SocketHandle):Result<Int>;
  42. /**
  43. Sets the size of the OS send buffer for a socket.
  44. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-set_send_buffer_size
  45. **/
  46. static public function setSendBufferSize(handle:SocketHandle, size:Int):Result<Result.NoData>;
  47. /**
  48. Gets the size of the OS receive buffer for a socket.
  49. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-recv_buffer_size
  50. **/
  51. static public function recvBufferSize(handle:SocketHandle):Result<Int>;
  52. /**
  53. Sets the size of the OS receive buffer for a socket.
  54. @see https://aantron.github.io/luv/luv/Luv/Handle/#val-set_recv_buffer_size
  55. **/
  56. static public function setRecvBufferSize(handle:SocketHandle, size:Int):Result<Result.NoData>;
  57. // TODO
  58. // /**
  59. // Retrieves the file descriptor associated with the handle.
  60. // @see https://aantron.github.io/luv/luv/Luv/Handle/#val-fileno
  61. // **/
  62. // static public function fileno(handle:FileNo):Result<OsFd>;
  63. }