{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/29309867","id":29309867,"diff_hunk":"@@ -723,3 +723,36 @@ function listenany(default_port)\n         end\n     end\n end\n+\n+function getsockname(sock::Union(TCPServer,TCPSocket))\n+    rport = Ref(UInt16(0))\n+    raddress = zeros(UInt8, 16)\n+    rfamily = Ref(UInt32(0))\n+    r = if isa(sock, TCPServer)\n+        ccall(:jl_tcp_getsockname, Int32,\n+                (Ptr{Void}, Ptr{UInt16}, Ptr{Void}, Ptr{UInt32}),\n+                sock.handle, rport, raddress, rfamily)\n+    else\n+        ccall(:jl_tcp_getpeername, Int32,\n+                (Ptr{Void}, Ptr{UInt16}, Ptr{Void}, Ptr{UInt32}),\n+                sock.handle, rport, raddress, rfamily)\n+    end\n+    addr = IPv4(UInt32(0))\n+    port = UInt16(0)\n+    if r == 0\n+        port = ntoh(getindex(rport))\n+        if getindex(rfamily) == 2 # AF_INET\n+            addrv4 = raddress[1:4]\n+            naddr = ntoh(unsafe_load(Ptr{UInt32}(pointer(addrv4)), 1))\n+            addr = IPv4(naddr)\n+        elseif getindex(rfamily) == 10 # AF_INET6\n+            naddr = ntoh(unsafe_load(Ptr{UInt128}(pointer(raddress)), 1))\n+            addr = IPv6(naddr)\n+        else\n+            warn(\"unsupported address family: $(getindex(rfamily))\")","path":"base/socket.jl","position":55,"original_position":55,"commit_id":"7c9f25b11b89d683974eb5656079f991dd77bf42","original_commit_id":"7c9f25b11b89d683974eb5656079f991dd77bf42","user":{"login":"vtjnash","id":330950,"avatar_url":"https://avatars.githubusercontent.com/u/330950?v=3","gravatar_id":"","url":"https://api.github.com/users/vtjnash","html_url":"https://github.com/vtjnash","followers_url":"https://api.github.com/users/vtjnash/followers","following_url":"https://api.github.com/users/vtjnash/following{/other_user}","gists_url":"https://api.github.com/users/vtjnash/gists{/gist_id}","starred_url":"https://api.github.com/users/vtjnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtjnash/subscriptions","organizations_url":"https://api.github.com/users/vtjnash/orgs","repos_url":"https://api.github.com/users/vtjnash/repos","events_url":"https://api.github.com/users/vtjnash/events{/privacy}","received_events_url":"https://api.github.com/users/vtjnash/received_events","type":"User","site_admin":false},"body":"this should be an error","created_at":"2015-04-29T04:33:43Z","updated_at":"2015-04-29T04:33:43Z","html_url":"https://github.com/JuliaLang/julia/pull/11012#discussion_r29309867","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/11012","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/29309867"},"html":{"href":"https://github.com/JuliaLang/julia/pull/11012#discussion_r29309867"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/11012"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/11012","id":34114835,"html_url":"https://github.com/JuliaLang/julia/pull/11012","diff_url":"https://github.com/JuliaLang/julia/pull/11012.diff","patch_url":"https://github.com/JuliaLang/julia/pull/11012.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/11012","number":11012,"state":"open","locked":false,"title":"added `getsockname` for determining a socket name (address & port) of the running server","user":{"login":"wildart","id":38350,"avatar_url":"https://avatars.githubusercontent.com/u/38350?v=3","gravatar_id":"","url":"https://api.github.com/users/wildart","html_url":"https://github.com/wildart","followers_url":"https://api.github.com/users/wildart/followers","following_url":"https://api.github.com/users/wildart/following{/other_user}","gists_url":"https://api.github.com/users/wildart/gists{/gist_id}","starred_url":"https://api.github.com/users/wildart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wildart/subscriptions","organizations_url":"https://api.github.com/users/wildart/orgs","repos_url":"https://api.github.com/users/wildart/repos","events_url":"https://api.github.com/users/wildart/events{/privacy}","received_events_url":"https://api.github.com/users/wildart/received_events","type":"User","site_admin":false},"body":"I added `getsockname` for determining a socket name (address & port) of the running server. When server socket bound to `INPORT_ANY` port (0), during `listen` call the socket is automatically bound to a random free port. By calling  `getsockname`, you can get value of the assigned port.\r\n\r\nIn addition, I fixed a missing IPv6 support for `bind` and some documentation.","created_at":"2015-04-25T23:19:17Z","updated_at":"2015-04-29T04:33:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86ae5b49878c33b71d7e698eab20ebb60d5576bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/11012/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/11012/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/11012/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/7c9f25b11b89d683974eb5656079f991dd77bf42","head":{"label":"wildart:getsockname","ref":"getsockname","sha":"7c9f25b11b89d683974eb5656079f991dd77bf42","user":{"login":"wildart","id":38350,"avatar_url":"https://avatars.githubusercontent.com/u/38350?v=3","gravatar_id":"","url":"https://api.github.com/users/wildart","html_url":"https://github.com/wildart","followers_url":"https://api.github.com/users/wildart/followers","following_url":"https://api.github.com/users/wildart/following{/other_user}","gists_url":"https://api.github.com/users/wildart/gists{/gist_id}","starred_url":"https://api.github.com/users/wildart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wildart/subscriptions","organizations_url":"https://api.github.com/users/wildart/orgs","repos_url":"https://api.github.com/users/wildart/repos","events_url":"https://api.github.com/users/wildart/events{/privacy}","received_events_url":"https://api.github.com/users/wildart/received_events","type":"User","site_admin":false},"repo":{"id":29095388,"name":"julia","full_name":"wildart/julia","owner":{"login":"wildart","id":38350,"avatar_url":"https://avatars.githubusercontent.com/u/38350?v=3","gravatar_id":"","url":"https://api.github.com/users/wildart","html_url":"https://github.com/wildart","followers_url":"https://api.github.com/users/wildart/followers","following_url":"https://api.github.com/users/wildart/following{/other_user}","gists_url":"https://api.github.com/users/wildart/gists{/gist_id}","starred_url":"https://api.github.com/users/wildart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wildart/subscriptions","organizations_url":"https://api.github.com/users/wildart/orgs","repos_url":"https://api.github.com/users/wildart/repos","events_url":"https://api.github.com/users/wildart/events{/privacy}","received_events_url":"https://api.github.com/users/wildart/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wildart/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/wildart/julia","forks_url":"https://api.github.com/repos/wildart/julia/forks","keys_url":"https://api.github.com/repos/wildart/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wildart/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wildart/julia/teams","hooks_url":"https://api.github.com/repos/wildart/julia/hooks","issue_events_url":"https://api.github.com/repos/wildart/julia/issues/events{/number}","events_url":"https://api.github.com/repos/wildart/julia/events","assignees_url":"https://api.github.com/repos/wildart/julia/assignees{/user}","branches_url":"https://api.github.com/repos/wildart/julia/branches{/branch}","tags_url":"https://api.github.com/repos/wildart/julia/tags","blobs_url":"https://api.github.com/repos/wildart/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wildart/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wildart/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/wildart/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wildart/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/wildart/julia/languages","stargazers_url":"https://api.github.com/repos/wildart/julia/stargazers","contributors_url":"https://api.github.com/repos/wildart/julia/contributors","subscribers_url":"https://api.github.com/repos/wildart/julia/subscribers","subscription_url":"https://api.github.com/repos/wildart/julia/subscription","commits_url":"https://api.github.com/repos/wildart/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/wildart/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/wildart/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/wildart/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/wildart/julia/contents/{+path}","compare_url":"https://api.github.com/repos/wildart/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wildart/julia/merges","archive_url":"https://api.github.com/repos/wildart/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wildart/julia/downloads","issues_url":"https://api.github.com/repos/wildart/julia/issues{/number}","pulls_url":"https://api.github.com/repos/wildart/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/wildart/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/wildart/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wildart/julia/labels{/name}","releases_url":"https://api.github.com/repos/wildart/julia/releases{/id}","created_at":"2015-01-11T15:06:47Z","updated_at":"2015-01-11T15:06:51Z","pushed_at":"2015-04-28T19:37:36Z","git_url":"git://github.com/wildart/julia.git","ssh_url":"git@github.com:wildart/julia.git","clone_url":"https://github.com/wildart/julia.git","svn_url":"https://github.com/wildart/julia","homepage":"http://julialang.org/","size":67946,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"a49e73288c9830959a1039855d433d41a3220146","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","created_at":"2011-04-21T07:01:50Z","updated_at":"2015-04-29T01:23:55Z","pushed_at":"2015-04-29T03:44:23Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":197545,"stargazers_count":5422,"watchers_count":5422,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1143,"mirror_url":null,"open_issues_count":1237,"forks":1143,"open_issues":1237,"watchers":5422,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/11012"},"html":{"href":"https://github.com/JuliaLang/julia/pull/11012"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/11012"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/11012/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/11012/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/11012/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/7c9f25b11b89d683974eb5656079f991dd77bf42"}}}}