{"action":"created","comment":{"url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/comments/46275910","id":46275910,"diff_hunk":"@@ -0,0 +1,125 @@\n+/*\n+ * Copyright (c) 2015, Ford Motor Company\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are met:\n+ *\n+ * Redistributions of source code must retain the above copyright notice, this\n+ * list of conditions and the following disclaimer.\n+ *\n+ * Redistributions in binary form must reproduce the above copyright notice,\n+ * this list of conditions and the following\n+ * disclaimer in the documentation and/or other materials provided with the\n+ * distribution.\n+ *\n+ * Neither the name of the Ford Motor Company nor the names of its contributors\n+ * may be used to endorse or promote products derived from this software\n+ * without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n+ * POSSIBILITY OF SUCH DAMAGE.\n+ */\n+#include <windows.h>\n+#include <winsock2.h>\n+\n+#include \"utils/socket.h\"\n+\n+namespace utils {\n+\n+class WinSocketImpl: public Socket::Impl {\n+ public:\n+  WinSocketImpl(int af, int type, int protocol);\n+  explicit WinSocketImpl(SOCKET socket);\n+  ~WinSocketImpl();\n+\n+  bool SetSocketOptions(\n+    int level, int optname,\n+    const char* optval, size_t optlen) OVERRIDE;\n+\n+  bool BindSocket(\n+    const struct sockaddr* addr, size_t addrlen) OVERRIDE;\n+\n+  bool ListenSocket(int backlog) OVERRIDE;\n+\n+  Socket AcceptSocket(\n+    struct sockaddr* addr, size_t addrlen) OVERRIDE;\n+\n+  size_t SendToSocket(\n+    const char* buf, size_t length, int flags) OVERRIDE;\n+\n+ private:\n+  SOCKET socket_;\n+};\n+\n+} // namespace utils\n+\n+\n+utils::Socket::Socket(int af, int type, int protocol): impl_(NULL) {\n+  impl_ = new WinSocketImpl(af, type, protocol);\n+}\n+\n+utils::WinSocketImpl::WinSocketImpl(int af, int type, int protocol)\n+  : socket_(NULL) {\n+  socket_ = socket(af, type, protocol);\n+  if (INVALID_SOCKET == socket_) {\n+    socket_ = NULL;\n+  }\n+}\n+\n+utils::WinSocketImpl::WinSocketImpl(SOCKET socket)\n+  : socket_(NULL) {\n+  if (INVALID_SOCKET == socket) {\n+    socket_ = NULL;\n+  } else {\n+    socket_ = socket;","path":"src/components/utils/src/socket_win.cc","position":84,"original_position":84,"commit_id":"d6b50ea5d6515200d22612194984ab80cd505ea3","original_commit_id":"d6b50ea5d6515200d22612194984ab80cd505ea3","user":{"login":"malirod","id":1135245,"avatar_url":"https://avatars.githubusercontent.com/u/1135245?v=3","gravatar_id":"","url":"https://api.github.com/users/malirod","html_url":"https://github.com/malirod","followers_url":"https://api.github.com/users/malirod/followers","following_url":"https://api.github.com/users/malirod/following{/other_user}","gists_url":"https://api.github.com/users/malirod/gists{/gist_id}","starred_url":"https://api.github.com/users/malirod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malirod/subscriptions","organizations_url":"https://api.github.com/users/malirod/orgs","repos_url":"https://api.github.com/users/malirod/repos","events_url":"https://api.github.com/users/malirod/events{/privacy}","received_events_url":"https://api.github.com/users/malirod/received_events","type":"User","site_admin":false},"body":"I personally prefer explicit if & else. There can the possibility to add some debug log line. Possibly just for debugging.  If & else suites better in such case. ","created_at":"2015-12-01T13:16:24Z","updated_at":"2015-12-01T13:16:24Z","html_url":"https://github.com/LuxoftSDL/sdl_core_winport/pull/24#discussion_r46275910","pull_request_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/comments/46275910"},"html":{"href":"https://github.com/LuxoftSDL/sdl_core_winport/pull/24#discussion_r46275910"},"pull_request":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24","id":52142158,"html_url":"https://github.com/LuxoftSDL/sdl_core_winport/pull/24","diff_url":"https://github.com/LuxoftSDL/sdl_core_winport/pull/24.diff","patch_url":"https://github.com/LuxoftSDL/sdl_core_winport/pull/24.patch","issue_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues/24","number":24,"state":"open","locked":false,"title":"Create net utils and move work with sockets there","user":{"login":"anosach-luxoft","id":11158680,"avatar_url":"https://avatars.githubusercontent.com/u/11158680?v=3","gravatar_id":"","url":"https://api.github.com/users/anosach-luxoft","html_url":"https://github.com/anosach-luxoft","followers_url":"https://api.github.com/users/anosach-luxoft/followers","following_url":"https://api.github.com/users/anosach-luxoft/following{/other_user}","gists_url":"https://api.github.com/users/anosach-luxoft/gists{/gist_id}","starred_url":"https://api.github.com/users/anosach-luxoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anosach-luxoft/subscriptions","organizations_url":"https://api.github.com/users/anosach-luxoft/orgs","repos_url":"https://api.github.com/users/anosach-luxoft/repos","events_url":"https://api.github.com/users/anosach-luxoft/events{/privacy}","received_events_url":"https://api.github.com/users/anosach-luxoft/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-30T16:01:30Z","updated_at":"2015-12-01T13:16:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbe8fb56919dc8eb93008711354f06eb0ab72e9a","assignee":{"login":"malirod","id":1135245,"avatar_url":"https://avatars.githubusercontent.com/u/1135245?v=3","gravatar_id":"","url":"https://api.github.com/users/malirod","html_url":"https://github.com/malirod","followers_url":"https://api.github.com/users/malirod/followers","following_url":"https://api.github.com/users/malirod/following{/other_user}","gists_url":"https://api.github.com/users/malirod/gists{/gist_id}","starred_url":"https://api.github.com/users/malirod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malirod/subscriptions","organizations_url":"https://api.github.com/users/malirod/orgs","repos_url":"https://api.github.com/users/malirod/repos","events_url":"https://api.github.com/users/malirod/events{/privacy}","received_events_url":"https://api.github.com/users/malirod/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24/commits","review_comments_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24/comments","review_comment_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues/24/comments","statuses_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/statuses/d6b50ea5d6515200d22612194984ab80cd505ea3","head":{"label":"anosach-luxoft:feature/Create-net-utils","ref":"feature/Create-net-utils","sha":"d6b50ea5d6515200d22612194984ab80cd505ea3","user":{"login":"anosach-luxoft","id":11158680,"avatar_url":"https://avatars.githubusercontent.com/u/11158680?v=3","gravatar_id":"","url":"https://api.github.com/users/anosach-luxoft","html_url":"https://github.com/anosach-luxoft","followers_url":"https://api.github.com/users/anosach-luxoft/followers","following_url":"https://api.github.com/users/anosach-luxoft/following{/other_user}","gists_url":"https://api.github.com/users/anosach-luxoft/gists{/gist_id}","starred_url":"https://api.github.com/users/anosach-luxoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anosach-luxoft/subscriptions","organizations_url":"https://api.github.com/users/anosach-luxoft/orgs","repos_url":"https://api.github.com/users/anosach-luxoft/repos","events_url":"https://api.github.com/users/anosach-luxoft/events{/privacy}","received_events_url":"https://api.github.com/users/anosach-luxoft/received_events","type":"User","site_admin":false},"repo":{"id":44157837,"name":"sdl_core_winport","full_name":"anosach-luxoft/sdl_core_winport","owner":{"login":"anosach-luxoft","id":11158680,"avatar_url":"https://avatars.githubusercontent.com/u/11158680?v=3","gravatar_id":"","url":"https://api.github.com/users/anosach-luxoft","html_url":"https://github.com/anosach-luxoft","followers_url":"https://api.github.com/users/anosach-luxoft/followers","following_url":"https://api.github.com/users/anosach-luxoft/following{/other_user}","gists_url":"https://api.github.com/users/anosach-luxoft/gists{/gist_id}","starred_url":"https://api.github.com/users/anosach-luxoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anosach-luxoft/subscriptions","organizations_url":"https://api.github.com/users/anosach-luxoft/orgs","repos_url":"https://api.github.com/users/anosach-luxoft/repos","events_url":"https://api.github.com/users/anosach-luxoft/events{/privacy}","received_events_url":"https://api.github.com/users/anosach-luxoft/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anosach-luxoft/sdl_core_winport","description":"","fork":true,"url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport","forks_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/forks","keys_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/teams","hooks_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/hooks","issue_events_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/issues/events{/number}","events_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/events","assignees_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/assignees{/user}","branches_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/branches{/branch}","tags_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/tags","blobs_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/git/refs{/sha}","trees_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/statuses/{sha}","languages_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/languages","stargazers_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/stargazers","contributors_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/contributors","subscribers_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/subscribers","subscription_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/subscription","commits_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/commits{/sha}","git_commits_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/git/commits{/sha}","comments_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/comments{/number}","issue_comment_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/issues/comments{/number}","contents_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/contents/{+path}","compare_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/merges","archive_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/downloads","issues_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/issues{/number}","pulls_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/pulls{/number}","milestones_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/milestones{/number}","notifications_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/labels{/name}","releases_url":"https://api.github.com/repos/anosach-luxoft/sdl_core_winport/releases{/id}","created_at":"2015-10-13T06:55:03Z","updated_at":"2015-10-13T06:55:14Z","pushed_at":"2015-12-01T11:37:08Z","git_url":"git://github.com/anosach-luxoft/sdl_core_winport.git","ssh_url":"git@github.com:anosach-luxoft/sdl_core_winport.git","clone_url":"https://github.com/anosach-luxoft/sdl_core_winport.git","svn_url":"https://github.com/anosach-luxoft/sdl_core_winport","homepage":null,"size":16844,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"LuxoftSDL:develop","ref":"develop","sha":"bae44cf06a1ea50018380bbbc62474a9477fd771","user":{"login":"LuxoftSDL","id":11190760,"avatar_url":"https://avatars.githubusercontent.com/u/11190760?v=3","gravatar_id":"","url":"https://api.github.com/users/LuxoftSDL","html_url":"https://github.com/LuxoftSDL","followers_url":"https://api.github.com/users/LuxoftSDL/followers","following_url":"https://api.github.com/users/LuxoftSDL/following{/other_user}","gists_url":"https://api.github.com/users/LuxoftSDL/gists{/gist_id}","starred_url":"https://api.github.com/users/LuxoftSDL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuxoftSDL/subscriptions","organizations_url":"https://api.github.com/users/LuxoftSDL/orgs","repos_url":"https://api.github.com/users/LuxoftSDL/repos","events_url":"https://api.github.com/users/LuxoftSDL/events{/privacy}","received_events_url":"https://api.github.com/users/LuxoftSDL/received_events","type":"Organization","site_admin":false},"repo":{"id":44124645,"name":"sdl_core_winport","full_name":"LuxoftSDL/sdl_core_winport","owner":{"login":"LuxoftSDL","id":11190760,"avatar_url":"https://avatars.githubusercontent.com/u/11190760?v=3","gravatar_id":"","url":"https://api.github.com/users/LuxoftSDL","html_url":"https://github.com/LuxoftSDL","followers_url":"https://api.github.com/users/LuxoftSDL/followers","following_url":"https://api.github.com/users/LuxoftSDL/following{/other_user}","gists_url":"https://api.github.com/users/LuxoftSDL/gists{/gist_id}","starred_url":"https://api.github.com/users/LuxoftSDL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuxoftSDL/subscriptions","organizations_url":"https://api.github.com/users/LuxoftSDL/orgs","repos_url":"https://api.github.com/users/LuxoftSDL/repos","events_url":"https://api.github.com/users/LuxoftSDL/events{/privacy}","received_events_url":"https://api.github.com/users/LuxoftSDL/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LuxoftSDL/sdl_core_winport","description":"","fork":false,"url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport","forks_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/forks","keys_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/teams","hooks_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/hooks","issue_events_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues/events{/number}","events_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/events","assignees_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/assignees{/user}","branches_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/branches{/branch}","tags_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/tags","blobs_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/git/refs{/sha}","trees_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/statuses/{sha}","languages_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/languages","stargazers_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/stargazers","contributors_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/contributors","subscribers_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/subscribers","subscription_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/subscription","commits_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/commits{/sha}","git_commits_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/git/commits{/sha}","comments_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/comments{/number}","issue_comment_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues/comments{/number}","contents_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/contents/{+path}","compare_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/merges","archive_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/downloads","issues_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues{/number}","pulls_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls{/number}","milestones_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/milestones{/number}","notifications_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/labels{/name}","releases_url":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/releases{/id}","created_at":"2015-10-12T17:59:45Z","updated_at":"2015-10-12T18:08:33Z","pushed_at":"2015-12-01T11:37:08Z","git_url":"git://github.com/LuxoftSDL/sdl_core_winport.git","ssh_url":"git@github.com:LuxoftSDL/sdl_core_winport.git","clone_url":"https://github.com/LuxoftSDL/sdl_core_winport.git","svn_url":"https://github.com/LuxoftSDL/sdl_core_winport","homepage":null,"size":17096,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24"},"html":{"href":"https://github.com/LuxoftSDL/sdl_core_winport/pull/24"},"issue":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues/24"},"comments":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/LuxoftSDL/sdl_core_winport/statuses/d6b50ea5d6515200d22612194984ab80cd505ea3"}}}}