Tcp.hx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package eval.luv;
  2. import haxe.ds.Option;
  3. import eval.luv.SockAddr;
  4. /**
  5. TCP sockets.
  6. @see https://aantron.github.io/luv/luv/Luv/TCP
  7. **/
  8. @:using(eval.luv.Handle)
  9. @:using(eval.luv.Stream)
  10. @:coreType abstract Tcp to Handle to Stream to Stream.TStream<Tcp> to Handle.SocketHandle {
  11. /**
  12. Allocates and initializes a TCP stream.
  13. The stream is not yet connected or listening.
  14. The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
  15. **/
  16. static public function init(loop:Loop, ?domain:AddressFamily):Result<Tcp>;
  17. /**
  18. Sets TCP_NODELAY.
  19. **/
  20. public function noDelay(enable:Bool):Result<Result.NoData>;
  21. /**
  22. Sets the TCP keepalive.
  23. **/
  24. public function keepAlive(value:Option<Int>):Result<Result.NoData>;
  25. /**
  26. Sets simultaneous accept.
  27. **/
  28. public function simultaneousAccepts(value:Bool):Result<Result.NoData>;
  29. /**
  30. Assigns an address to the TCP socket.
  31. **/
  32. public function bind(addr:SockAddr, ipv6Only:Bool = false):Result<Result.NoData>;
  33. /**
  34. Retrieves the address assigned to the TCP socket.
  35. **/
  36. public function getSockName():Result<SockAddr>;
  37. /**
  38. Retrieves the address of the TCP socket's peer.
  39. **/
  40. public function getPeerName():Result<SockAddr>;
  41. /**
  42. Connects to a host.
  43. **/
  44. public function connect(addr:SockAddr, callback:(result:Result<Result.NoData>)->Void):Void;
  45. /**
  46. Resets the connection.
  47. **/
  48. public function closeReset(callback:(result:Result<Result.NoData>)->Void):Void;
  49. }