{"action":"created","issue":{"url":"https://api.github.com/repos/ponylang/ponyc/issues/2587","repository_url":"https://api.github.com/repos/ponylang/ponyc","labels_url":"https://api.github.com/repos/ponylang/ponyc/issues/2587/labels{/name}","comments_url":"https://api.github.com/repos/ponylang/ponyc/issues/2587/comments","events_url":"https://api.github.com/repos/ponylang/ponyc/issues/2587/events","html_url":"https://github.com/ponylang/ponyc/issues/2587","id":303520019,"number":2587,"title":"NetAdress is instantiated with wrong fields on linux","user":{"login":"mfelsche","id":1152667,"avatar_url":"https://avatars0.githubusercontent.com/u/1152667?v=4","gravatar_id":"","url":"https://api.github.com/users/mfelsche","html_url":"https://github.com/mfelsche","followers_url":"https://api.github.com/users/mfelsche/followers","following_url":"https://api.github.com/users/mfelsche/following{/other_user}","gists_url":"https://api.github.com/users/mfelsche/gists{/gist_id}","starred_url":"https://api.github.com/users/mfelsche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfelsche/subscriptions","organizations_url":"https://api.github.com/users/mfelsche/orgs","repos_url":"https://api.github.com/users/mfelsche/repos","events_url":"https://api.github.com/users/mfelsche/events{/privacy}","received_events_url":"https://api.github.com/users/mfelsche/received_events","type":"User","site_admin":false},"labels":[{"id":687774754,"url":"https://api.github.com/repos/ponylang/ponyc/labels/Help%20Wanted","name":"Help Wanted","color":"fbca04","default":false},{"id":337110571,"url":"https://api.github.com/repos/ponylang/ponyc/labels/bug:%201%20-%20needs%20investigation","name":"bug: 1 - needs investigation","color":"f7c6c7","default":false},{"id":283122481,"url":"https://api.github.com/repos/ponylang/ponyc/labels/complexity:%20requires%20context","name":"complexity: requires context","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-08T15:26:36Z","updated_at":"2018-03-08T19:59:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"[NetAddress](https://stdlib.ponylang.org/net-NetAddress/) is instantiated with confusing values on linux both when resolving a hostname using `DNS.apply(...)` or opening a listening socket via `TCPListener`.\r\n\r\nThe `length` field gets a value of `2` for ipv4 addresses and `10` for ipv6 addresses, which corresponds to the `AF_INET` and `AF_INET6` values on my machine (see below). The `family` field is always `0` no matter what i do.\r\n\r\n--- \r\n`AF_INET` defines on my machine:\r\n\r\n```\r\n/usr/include/x86_64-linux-gnu/bits/socket.h\r\n45:#define PF_INET\t\t2\t/* IP protocol family.  */\r\n53:#define PF_INET6\t10\t/* IP version 6.  */\r\n92:#define AF_INET\t\tPF_INET\r\n100:#define AF_INET6\tPF_INET6\r\n```\r\n\r\nSystem information:\r\n```\r\n$ uname -a\r\nLinux hostname 4.13.0-36-generic #40~16.04.1-Ubuntu SMP Fri Feb 16 23:25:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\r\n\r\n$ ponc --version\r\n0.21.3-d34dce6 [debug]\r\ncompiled with: llvm 3.9.1 -- cc (Ubuntu 5.4.0-6ubuntu1~16.04.6) 5.4.0 20160609\r\nDefaults: pic=false ssl=openssl_0.9.0\r\n```\r\n\r\n**Can someone test/confirm this behaviour on Windows/OSX/BSD with the following small program?**\r\n\r\n```pony\r\nuse \"net\"\r\n\r\nprimitive AddressPrinter\r\n\r\n  fun print_address(out: OutStream, a: NetAddress) =>\r\n    out.write(\"\\n\")\r\n    out.print(\"length: \" + a.length.string())\r\n    out.print(\"family: \" + a.family.string())\r\n    out.print(\"port (network, host): \" + a.port.string() + \", \" + @ntohs[U16](a.port).string())\r\n    out.print(\"addr: \" + a.addr.string())\r\n    let addr = @ntohl[U32](a.addr)\r\n    out.print(\r\n      (addr >> 24).u8().string() + \".\" +\r\n      (addr >> 16).u8().string() + \".\" +\r\n      (addr >> 8).u8().string() + \".\" +\r\n      (addr).u8().string())\r\n    out.print(\"addr1: \" + a.addr1.string())\r\n    out.print(\"addr2: \" + a.addr2.string())\r\n    out.print(\"addr3: \" + a.addr3.string())\r\n    out.print(\"addr4: \" + a.addr4.string())\r\n    out.print(\"scope: \" + a.scope.string())\r\n\r\n\r\nactor Main\r\n\r\n  new create(env: Env) =>\r\n    try\r\n      let resolved = DNS(env.root as AmbientAuth, \"google.com\", \"80\")\r\n      for a in (consume resolved).values() do\r\n        AddressPrinter.print_address(env.out, a)\r\n      end\r\n    end\r\n\r\n    try\r\n      TCPListener.ip6(env.root as AmbientAuth,\r\n        recover MyTCPListenNotify(env) end, \"\", \"0\")\r\n    end\r\n\r\n  class MyTCPConnectionNotify is TCPConnectionNotify\r\n    fun ref received(\r\n      conn: TCPConnection ref,\r\n      data: Array[U8] iso,\r\n      times: USize)\r\n      : Bool\r\n    =>\r\n      conn.write(String.from_array(consume data))\r\n      true\r\n\r\n    fun ref connect_failed(conn: TCPConnection ref) =>\r\n      None\r\n\r\n  class MyTCPListenNotify is TCPListenNotify\r\n\r\n    let _env: Env\r\n    let _start_ip4: Bool\r\n\r\n    new create(env: Env, start_ip4: Bool=true) =>\r\n      _env = env\r\n      _start_ip4 = start_ip4\r\n\r\n    fun ref connected(listen: TCPListener ref): TCPConnectionNotify iso^ =>\r\n      MyTCPConnectionNotify\r\n\r\n    fun ref listening(listen: TCPListener ref) =>\r\n      AddressPrinter.print_address(_env.out, listen.local_address())\r\n      listen.dispose()\r\n\r\n      if _start_ip4 then\r\n        try\r\n          TCPListener.ip4(_env.root as AmbientAuth,\r\n            recover MyTCPListenNotify(_env, false) end, \"\", \"0\")\r\n        end\r\n      end\r\n\r\n    fun ref not_listening(listen: TCPListener ref) =>\r\n      None\r\n```"},"comment":{"url":"https://api.github.com/repos/ponylang/ponyc/issues/comments/371606093","html_url":"https://github.com/ponylang/ponyc/issues/2587#issuecomment-371606093","issue_url":"https://api.github.com/repos/ponylang/ponyc/issues/2587","id":371606093,"user":{"login":"mfelsche","id":1152667,"avatar_url":"https://avatars0.githubusercontent.com/u/1152667?v=4","gravatar_id":"","url":"https://api.github.com/users/mfelsche","html_url":"https://github.com/mfelsche","followers_url":"https://api.github.com/users/mfelsche/followers","following_url":"https://api.github.com/users/mfelsche/following{/other_user}","gists_url":"https://api.github.com/users/mfelsche/gists{/gist_id}","starred_url":"https://api.github.com/users/mfelsche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfelsche/subscriptions","organizations_url":"https://api.github.com/users/mfelsche/orgs","repos_url":"https://api.github.com/users/mfelsche/repos","events_url":"https://api.github.com/users/mfelsche/events{/privacy}","received_events_url":"https://api.github.com/users/mfelsche/received_events","type":"User","site_admin":false},"created_at":"2018-03-08T19:59:55Z","updated_at":"2018-03-08T19:59:55Z","author_association":"CONTRIBUTOR","body":"Thank you very much.\r\n\r\nThis confirms that OSX and FreeBSD don't seem to be affected."}}
{"actor":{"display_login":"mfelsche"}}