{"action":"created","issue":{"url":"https://api.github.com/repos/tokuhirom/Test-TCP/issues/18","labels_url":"https://api.github.com/repos/tokuhirom/Test-TCP/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/tokuhirom/Test-TCP/issues/18/comments","events_url":"https://api.github.com/repos/tokuhirom/Test-TCP/issues/18/events","html_url":"https://github.com/tokuhirom/Test-TCP/issues/18","id":15949498,"number":18,"title":"use port 0 rather than Net::EmptyPort","user":{"login":"karenetheridge","id":303051,"avatar_url":"https://avatars.githubusercontent.com/u/303051?v=3","gravatar_id":"","url":"https://api.github.com/users/karenetheridge","html_url":"https://github.com/karenetheridge","followers_url":"https://api.github.com/users/karenetheridge/followers","following_url":"https://api.github.com/users/karenetheridge/following{/other_user}","gists_url":"https://api.github.com/users/karenetheridge/gists{/gist_id}","starred_url":"https://api.github.com/users/karenetheridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karenetheridge/subscriptions","organizations_url":"https://api.github.com/users/karenetheridge/orgs","repos_url":"https://api.github.com/users/karenetheridge/repos","events_url":"https://api.github.com/users/karenetheridge/events{/privacy}","received_events_url":"https://api.github.com/users/karenetheridge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2013-06-24T21:48:34Z","updated_at":"2015-04-16T21:59:01Z","closed_at":null,"body":"from #plack:\r\n\r\n13:56 < ether> hmm, it looks like Test::TCP *is* looking for an empty port..  but because this is an active server, the port it selected becomes unavailable before it can start the test  \r\n13:56 < ether> at least, this is what it looks like  \r\n13:56 < ether> perhaps there could be a way to disable tests that actively use the network?  \r\n13:57 < ether> or, loop until a free port is *really* found  \r\n13:57 < leedo> ether: yeah, i'm confused by Test::TCP doesn't bind to 0. i think that chooses a random open port  \r\n13:57 < leedo> maybe it isn't cross platform, though  \r\n13:59 < leedo> last i looked it did a while loop looking for open ports  \r\n14:19 < sri> this works pretty well in mojolicious so far for finding a free port https://github.com/kraih/mojo/blob/master/lib/Mojo/IOLoop/Server.pm#L100  \r\n14:20 < sri> pretty sure it actually predates Test::TCP  \r\n14:22 < sri> think there has been exactly one bug report over the years, and that was some broken version of cygwin... (more broken than usual)  \r\n14:24 < sri> (mojolicious always runs a few thousand tests that actively use the network)  \r\n14:26 < sri> oops, i misunderstood the problem... ignore me :)  \r\n14:26 < sri> or kinda...  \r\n14:27 < sri> bind to random port has the advantage that the operating system puts a cooldown on it, so it's not reused right away  \r\n14:27 < sri> misunderstood the problem... but the solution is still valid ;p  \r\n14:29 < sri> Net::EmptyPort is just weird  \r\n14:34 < leedo> yes, i'd be curious to see the reason for some of that  \r\n"},"comment":{"url":"https://api.github.com/repos/tokuhirom/Test-TCP/issues/comments/93849131","html_url":"https://github.com/tokuhirom/Test-TCP/issues/18#issuecomment-93849131","issue_url":"https://api.github.com/repos/tokuhirom/Test-TCP/issues/18","id":93849131,"user":{"login":"kazuho","id":41567,"avatar_url":"https://avatars.githubusercontent.com/u/41567?v=3","gravatar_id":"","url":"https://api.github.com/users/kazuho","html_url":"https://github.com/kazuho","followers_url":"https://api.github.com/users/kazuho/followers","following_url":"https://api.github.com/users/kazuho/following{/other_user}","gists_url":"https://api.github.com/users/kazuho/gists{/gist_id}","starred_url":"https://api.github.com/users/kazuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kazuho/subscriptions","organizations_url":"https://api.github.com/users/kazuho/orgs","repos_url":"https://api.github.com/users/kazuho/repos","events_url":"https://api.github.com/users/kazuho/events{/privacy}","received_events_url":"https://api.github.com/users/kazuho/received_events","type":"User","site_admin":false},"created_at":"2015-04-16T21:59:01Z","updated_at":"2015-04-16T21:59:01Z","body":"@bjakubski \r\n> I think that this known race condition (which is impossible to get rid of because of how API is designed) should get prominent notice in docs.\r\n\r\nAgreed.  That is definitely something nice to have.\r\n\r\n> Probably it should mention that for reliable random port assignment \"port 0 trick\" (if possible to use) is better.\r\n\r\nIMO, if it is a better approach, then we should switch to it.  If it is not, we should not mention as such.  And my understanding regarding the issue is that using ephemeral ports for the purpose is not a good idea, as pointed out in my previous comment.\r\n\r\n> Possibly unix domain sockets should also get a mention (great solution for testing when client and server allow that.\r\n\r\nI would suspect that nobody would argue against adding support for unix-sockets to Test::TCP."}}