SockAddr.hx 817 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package eval.luv;
  2. /**
  3. Network address families.
  4. **/
  5. enum AddressFamily {
  6. UNSPEC;
  7. INET;
  8. INET6;
  9. OTHER(i:Int);
  10. }
  11. /**
  12. Socket types.
  13. **/
  14. enum SocketType {
  15. STREAM;
  16. DGRAM;
  17. RAW;
  18. OTHER(i:Int);
  19. }
  20. /**
  21. Binds `struct sockaddr`.
  22. @see https://aantron.github.io/luv/luv/Luv/Sockaddr
  23. **/
  24. @:coreType abstract SockAddr {
  25. /** Extracts the port in a network address. */
  26. public var port(get,never):Null<Int>;
  27. function get_port():Null<Int>;
  28. /**
  29. Converts a string and port number to an IPv4 struct sockaddr.
  30. **/
  31. static public function ipv4(host:String, port:Int):Result<SockAddr>;
  32. /**
  33. Converts a string and port number to an IPv6 struct sockaddr.
  34. **/
  35. static public function ipv6(host:String, port:Int):Result<SockAddr>;
  36. /**
  37. Converts a network address to a string.
  38. **/
  39. public function toString():String;
  40. }