{"action":"created","comment":{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/comments/59994671","id":59994671,"diff_hunk":"@@ -0,0 +1,67 @@\n+// Part of measurement-kit <https://measurement-kit.github.io/>.\n+// Measurement-kit is free software. See AUTHORS and LICENSE for more\n+// information on the copying conditions.\n+#ifndef SRC_NET_CONNECT_MANY_HPP\n+#define SRC_NET_CONNECT_MANY_HPP\n+\n+#include <functional>\n+#include <measurement_kit/common.hpp>\n+#include <measurement_kit/net.hpp>\n+#include <string>\n+#include <vector>\n+\n+namespace mk {\n+namespace net {\n+\n+class ConnectManyCtx {\n+  public:\n+    int left = 0; // Signed to detect programmer errors\n+    ConnectManyCb callback;\n+    std::vector<Var<Transport>> connections;\n+    std::string address;\n+    int port = 0;\n+    Settings settings;\n+    Logger *logger = Logger::global();\n+    Poller *poller = Poller::global();\n+};\n+\n+template <void (*do_connect)(std::string, int,\n+              std::function<void(Error, Var<Transport>)>, Settings, Logger *,\n+              Poller *) = net::connect>\n+static void connect_many_(Var<ConnectManyCtx> ctx) {\n+    // Implementation note: this function connects sequentially, which\n+    // is slower but also much simpler to implement and verify\n+    if (ctx->left <= 0) {\n+        ctx->callback(NoError(), ctx->connections);\n+        return;\n+    }\n+    do_connect(ctx->address, ctx->port,\n+        [=](Error err, Var<Transport> txp) {\n+            if (err) {\n+                ctx->callback(err, ctx->connections);\n+                return;\n+            }\n+            ctx->connections.push_back(txp);\n+            --ctx->left;\n+            connect_many_<do_connect>(ctx);\n+        },\n+        ctx->settings, ctx->logger, ctx->poller);\n+}\n+\n+static Var<ConnectManyCtx> connect_many_make(std::string address, int port,","path":"src/net/connect-many.hpp","position":51,"original_position":51,"commit_id":"d20da25f768c4dbf02581c4213ea586197606752","original_commit_id":"f2be2a2fa7ace390d71f0713b70ed1ed922613e7","user":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"body":"I understand you comment. I think it's more or less the same because you can refactor one thing into the other. In this case I preferred to not mix the class and methods style and the struct and functions style, since this file in particular is totally implemented using the latter.","created_at":"2016-04-17T22:41:17Z","updated_at":"2016-04-17T22:41:17Z","html_url":"https://github.com/measurement-kit/measurement-kit/pull/467#discussion_r59994671","pull_request_url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467","_links":{"self":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/comments/59994671"},"html":{"href":"https://github.com/measurement-kit/measurement-kit/pull/467#discussion_r59994671"},"pull_request":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467"}}},"pull_request":{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467","id":66507130,"html_url":"https://github.com/measurement-kit/measurement-kit/pull/467","diff_url":"https://github.com/measurement-kit/measurement-kit/pull/467.diff","patch_url":"https://github.com/measurement-kit/measurement-kit/pull/467.patch","issue_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/467","number":467,"state":"open","locked":false,"title":"Implement connect_many() required by NDT","user":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"body":"There is a case where the NDT client could open more than one connection to the remote server. Add code in `net` to allow to implement that use case. Also add regress tests.","created_at":"2016-04-14T15:43:34Z","updated_at":"2016-04-17T22:41:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c933413c6679fca726324aca7f6cc3c3e71eaa24","assignee":{"login":"AntonioLangiu","id":4649406,"avatar_url":"https://avatars.githubusercontent.com/u/4649406?v=3","gravatar_id":"","url":"https://api.github.com/users/AntonioLangiu","html_url":"https://github.com/AntonioLangiu","followers_url":"https://api.github.com/users/AntonioLangiu/followers","following_url":"https://api.github.com/users/AntonioLangiu/following{/other_user}","gists_url":"https://api.github.com/users/AntonioLangiu/gists{/gist_id}","starred_url":"https://api.github.com/users/AntonioLangiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AntonioLangiu/subscriptions","organizations_url":"https://api.github.com/users/AntonioLangiu/orgs","repos_url":"https://api.github.com/users/AntonioLangiu/repos","events_url":"https://api.github.com/users/AntonioLangiu/events{/privacy}","received_events_url":"https://api.github.com/users/AntonioLangiu/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/milestones/6","html_url":"https://github.com/measurement-kit/measurement-kit/milestones/release-0.3.0","labels_url":"https://api.github.com/repos/measurement-kit/measurement-kit/milestones/6/labels","id":1413151,"number":6,"title":"release-0.3.0","description":"- ndt client (first version)\r\n- async jni api for ooni\r\n- tor support\r\n- more ooni tests?\r\n- add support for uTP?\r\n- fixes","creator":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":0,"state":"open","created_at":"2015-11-16T08:46:36Z","updated_at":"2016-04-16T18:35:26Z","due_on":"2016-06-14T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467/commits","review_comments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467/comments","review_comment_url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/467/comments","statuses_url":"https://api.github.com/repos/measurement-kit/measurement-kit/statuses/d20da25f768c4dbf02581c4213ea586197606752","head":{"label":"measurement-kit:feature/connect-many","ref":"feature/connect-many","sha":"d20da25f768c4dbf02581c4213ea586197606752","user":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"repo":{"id":20287787,"name":"measurement-kit","full_name":"measurement-kit/measurement-kit","owner":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/measurement-kit/measurement-kit","description":"Portable C++11 network measurement library","fork":false,"url":"https://api.github.com/repos/measurement-kit/measurement-kit","forks_url":"https://api.github.com/repos/measurement-kit/measurement-kit/forks","keys_url":"https://api.github.com/repos/measurement-kit/measurement-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/measurement-kit/measurement-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/measurement-kit/measurement-kit/teams","hooks_url":"https://api.github.com/repos/measurement-kit/measurement-kit/hooks","issue_events_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/events{/number}","events_url":"https://api.github.com/repos/measurement-kit/measurement-kit/events","assignees_url":"https://api.github.com/repos/measurement-kit/measurement-kit/assignees{/user}","branches_url":"https://api.github.com/repos/measurement-kit/measurement-kit/branches{/branch}","tags_url":"https://api.github.com/repos/measurement-kit/measurement-kit/tags","blobs_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/measurement-kit/measurement-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/measurement-kit/measurement-kit/languages","stargazers_url":"https://api.github.com/repos/measurement-kit/measurement-kit/stargazers","contributors_url":"https://api.github.com/repos/measurement-kit/measurement-kit/contributors","subscribers_url":"https://api.github.com/repos/measurement-kit/measurement-kit/subscribers","subscription_url":"https://api.github.com/repos/measurement-kit/measurement-kit/subscription","commits_url":"https://api.github.com/repos/measurement-kit/measurement-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/measurement-kit/measurement-kit/contents/{+path}","compare_url":"https://api.github.com/repos/measurement-kit/measurement-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/measurement-kit/measurement-kit/merges","archive_url":"https://api.github.com/repos/measurement-kit/measurement-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/measurement-kit/measurement-kit/downloads","issues_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues{/number}","pulls_url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/measurement-kit/measurement-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/measurement-kit/measurement-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/measurement-kit/measurement-kit/labels{/name}","releases_url":"https://api.github.com/repos/measurement-kit/measurement-kit/releases{/id}","deployments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/deployments","created_at":"2014-05-29T08:44:43Z","updated_at":"2016-04-06T15:30:13Z","pushed_at":"2016-04-17T21:07:31Z","git_url":"git://github.com/measurement-kit/measurement-kit.git","ssh_url":"git@github.com:measurement-kit/measurement-kit.git","clone_url":"https://github.com/measurement-kit/measurement-kit.git","svn_url":"https://github.com/measurement-kit/measurement-kit","homepage":"https://measurement-kit.github.io/","size":10354,"stargazers_count":16,"watchers_count":16,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":59,"forks":4,"open_issues":59,"watchers":16,"default_branch":"master"}},"base":{"label":"measurement-kit:master","ref":"master","sha":"e567eee0a6f16ba6d03587e2c349adf9bc322be0","user":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"repo":{"id":20287787,"name":"measurement-kit","full_name":"measurement-kit/measurement-kit","owner":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/measurement-kit/measurement-kit","description":"Portable C++11 network measurement library","fork":false,"url":"https://api.github.com/repos/measurement-kit/measurement-kit","forks_url":"https://api.github.com/repos/measurement-kit/measurement-kit/forks","keys_url":"https://api.github.com/repos/measurement-kit/measurement-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/measurement-kit/measurement-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/measurement-kit/measurement-kit/teams","hooks_url":"https://api.github.com/repos/measurement-kit/measurement-kit/hooks","issue_events_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/events{/number}","events_url":"https://api.github.com/repos/measurement-kit/measurement-kit/events","assignees_url":"https://api.github.com/repos/measurement-kit/measurement-kit/assignees{/user}","branches_url":"https://api.github.com/repos/measurement-kit/measurement-kit/branches{/branch}","tags_url":"https://api.github.com/repos/measurement-kit/measurement-kit/tags","blobs_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/measurement-kit/measurement-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/measurement-kit/measurement-kit/languages","stargazers_url":"https://api.github.com/repos/measurement-kit/measurement-kit/stargazers","contributors_url":"https://api.github.com/repos/measurement-kit/measurement-kit/contributors","subscribers_url":"https://api.github.com/repos/measurement-kit/measurement-kit/subscribers","subscription_url":"https://api.github.com/repos/measurement-kit/measurement-kit/subscription","commits_url":"https://api.github.com/repos/measurement-kit/measurement-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/measurement-kit/measurement-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/measurement-kit/measurement-kit/contents/{+path}","compare_url":"https://api.github.com/repos/measurement-kit/measurement-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/measurement-kit/measurement-kit/merges","archive_url":"https://api.github.com/repos/measurement-kit/measurement-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/measurement-kit/measurement-kit/downloads","issues_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues{/number}","pulls_url":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/measurement-kit/measurement-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/measurement-kit/measurement-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/measurement-kit/measurement-kit/labels{/name}","releases_url":"https://api.github.com/repos/measurement-kit/measurement-kit/releases{/id}","deployments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/deployments","created_at":"2014-05-29T08:44:43Z","updated_at":"2016-04-06T15:30:13Z","pushed_at":"2016-04-17T21:07:31Z","git_url":"git://github.com/measurement-kit/measurement-kit.git","ssh_url":"git@github.com:measurement-kit/measurement-kit.git","clone_url":"https://github.com/measurement-kit/measurement-kit.git","svn_url":"https://github.com/measurement-kit/measurement-kit","homepage":"https://measurement-kit.github.io/","size":10354,"stargazers_count":16,"watchers_count":16,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":59,"forks":4,"open_issues":59,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467"},"html":{"href":"https://github.com/measurement-kit/measurement-kit/pull/467"},"issue":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/467"},"comments":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/467/comments"},"review_comments":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467/comments"},"review_comment":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/pulls/467/commits"},"statuses":{"href":"https://api.github.com/repos/measurement-kit/measurement-kit/statuses/d20da25f768c4dbf02581c4213ea586197606752"}}}}