{"action":"created","comment":{"url":"https://api.github.com/repos/VeniceX/TCP/pulls/comments/58984925","id":58984925,"diff_hunk":"@@ -0,0 +1,72 @@\n+// TCPServer.swift\n+//\n+// The MIT License (MIT)\n+//\n+// Copyright (c) 2015 Zewo\n+//\n+// Permission is hereby granted, free of charge, to any person obtaining a copy\n+// of this software and associated documentation files (the \"Software\"), to deal\n+// in the Software without restriction, including without limitation the rights\n+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+// copies of the Software, and to permit persons to whom the Software is\n+// furnished to do so, subject to the following conditions:\n+//\n+// The above copyright notice and this permission notice shall be included in all\n+// copies or substantial portions of the Software.\n+//\n+// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+// SOFTWARE.\n+\n+import CLibvenice\n+import C7\n+\n+public final class TCPServer {\n+    \n+    public var uri: C7.URI\n+    private let backlog: Int32\n+    private let reusePort: Bool\n+    private var socket: tcpsock\n+    private var connection: TCPConnection?\n+    \n+    public init(for uri: URI) throws {\n+        self.uri = uri\n+        backlog = 128\n+        reusePort = false\n+        \n+        guard let host = uri.host else {\n+            throw TCPError.unknown(description: \"Host was not defined in URI\")\n+        }\n+        guard let port = uri.port else {\n+            throw TCPError.unknown(description: \"Port was not defined in URI\")\n+        }\n+        \n+        let ip = try IP(remoteAddress: host, port: port)\n+        socket = tcplisten(ip.address, self.backlog, reusePort ? 1 : 0)\n+    }\n+    \n+    public init(for uri: URI, backlog: Int = 128, reusePort: Bool = false) throws {\n+        self.uri = uri","path":"Source/TCPServer.swift","position":53,"original_position":53,"commit_id":"ab30e1b6627e902824f83c8de984cf1782e15b55","original_commit_id":"ab30e1b6627e902824f83c8de984cf1782e15b55","user":{"login":"paulofaria","id":5126193,"avatar_url":"https://avatars.githubusercontent.com/u/5126193?v=3","gravatar_id":"","url":"https://api.github.com/users/paulofaria","html_url":"https://github.com/paulofaria","followers_url":"https://api.github.com/users/paulofaria/followers","following_url":"https://api.github.com/users/paulofaria/following{/other_user}","gists_url":"https://api.github.com/users/paulofaria/gists{/gist_id}","starred_url":"https://api.github.com/users/paulofaria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulofaria/subscriptions","organizations_url":"https://api.github.com/users/paulofaria/orgs","repos_url":"https://api.github.com/users/paulofaria/repos","events_url":"https://api.github.com/users/paulofaria/events{/privacy}","received_events_url":"https://api.github.com/users/paulofaria/received_events","type":"User","site_admin":false},"body":"```swift\r\npublic init(for uri: URI, queuing backlog: Int = 128, reusingPort reusePort: Bool) throws\r\n```","created_at":"2016-04-08T06:31:52Z","updated_at":"2016-04-08T06:31:52Z","html_url":"https://github.com/VeniceX/TCP/pull/2#discussion_r58984925","pull_request_url":"https://api.github.com/repos/VeniceX/TCP/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/VeniceX/TCP/pulls/comments/58984925"},"html":{"href":"https://github.com/VeniceX/TCP/pull/2#discussion_r58984925"},"pull_request":{"href":"https://api.github.com/repos/VeniceX/TCP/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/VeniceX/TCP/pulls/2","id":65575620,"html_url":"https://github.com/VeniceX/TCP/pull/2","diff_url":"https://github.com/VeniceX/TCP/pull/2.diff","patch_url":"https://github.com/VeniceX/TCP/pull/2.patch","issue_url":"https://api.github.com/repos/VeniceX/TCP/issues/2","number":2,"state":"open","locked":false,"title":"Refactor to conform to C7.Connection - Factored out sockets","user":{"login":"scottbyrns","id":290248,"avatar_url":"https://avatars.githubusercontent.com/u/290248?v=3","gravatar_id":"","url":"https://api.github.com/users/scottbyrns","html_url":"https://github.com/scottbyrns","followers_url":"https://api.github.com/users/scottbyrns/followers","following_url":"https://api.github.com/users/scottbyrns/following{/other_user}","gists_url":"https://api.github.com/users/scottbyrns/gists{/gist_id}","starred_url":"https://api.github.com/users/scottbyrns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottbyrns/subscriptions","organizations_url":"https://api.github.com/users/scottbyrns/orgs","repos_url":"https://api.github.com/users/scottbyrns/repos","events_url":"https://api.github.com/users/scottbyrns/events{/privacy}","received_events_url":"https://api.github.com/users/scottbyrns/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-07T05:24:36Z","updated_at":"2016-04-08T06:31:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"792df7218a0ad6add78f8363a99dfb1573aaab97","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/VeniceX/TCP/pulls/2/commits","review_comments_url":"https://api.github.com/repos/VeniceX/TCP/pulls/2/comments","review_comment_url":"https://api.github.com/repos/VeniceX/TCP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VeniceX/TCP/issues/2/comments","statuses_url":"https://api.github.com/repos/VeniceX/TCP/statuses/ab30e1b6627e902824f83c8de984cf1782e15b55","head":{"label":"VeniceX:TCPConnection","ref":"TCPConnection","sha":"ab30e1b6627e902824f83c8de984cf1782e15b55","user":{"login":"VeniceX","id":17913063,"avatar_url":"https://avatars.githubusercontent.com/u/17913063?v=3","gravatar_id":"","url":"https://api.github.com/users/VeniceX","html_url":"https://github.com/VeniceX","followers_url":"https://api.github.com/users/VeniceX/followers","following_url":"https://api.github.com/users/VeniceX/following{/other_user}","gists_url":"https://api.github.com/users/VeniceX/gists{/gist_id}","starred_url":"https://api.github.com/users/VeniceX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VeniceX/subscriptions","organizations_url":"https://api.github.com/users/VeniceX/orgs","repos_url":"https://api.github.com/users/VeniceX/repos","events_url":"https://api.github.com/users/VeniceX/events{/privacy}","received_events_url":"https://api.github.com/users/VeniceX/received_events","type":"Organization","site_admin":false},"repo":{"id":51792099,"name":"TCP","full_name":"VeniceX/TCP","owner":{"login":"VeniceX","id":17913063,"avatar_url":"https://avatars.githubusercontent.com/u/17913063?v=3","gravatar_id":"","url":"https://api.github.com/users/VeniceX","html_url":"https://github.com/VeniceX","followers_url":"https://api.github.com/users/VeniceX/followers","following_url":"https://api.github.com/users/VeniceX/following{/other_user}","gists_url":"https://api.github.com/users/VeniceX/gists{/gist_id}","starred_url":"https://api.github.com/users/VeniceX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VeniceX/subscriptions","organizations_url":"https://api.github.com/users/VeniceX/orgs","repos_url":"https://api.github.com/users/VeniceX/repos","events_url":"https://api.github.com/users/VeniceX/events{/privacy}","received_events_url":"https://api.github.com/users/VeniceX/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VeniceX/TCP","description":"TCP sockets","fork":false,"url":"https://api.github.com/repos/VeniceX/TCP","forks_url":"https://api.github.com/repos/VeniceX/TCP/forks","keys_url":"https://api.github.com/repos/VeniceX/TCP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VeniceX/TCP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VeniceX/TCP/teams","hooks_url":"https://api.github.com/repos/VeniceX/TCP/hooks","issue_events_url":"https://api.github.com/repos/VeniceX/TCP/issues/events{/number}","events_url":"https://api.github.com/repos/VeniceX/TCP/events","assignees_url":"https://api.github.com/repos/VeniceX/TCP/assignees{/user}","branches_url":"https://api.github.com/repos/VeniceX/TCP/branches{/branch}","tags_url":"https://api.github.com/repos/VeniceX/TCP/tags","blobs_url":"https://api.github.com/repos/VeniceX/TCP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VeniceX/TCP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VeniceX/TCP/git/refs{/sha}","trees_url":"https://api.github.com/repos/VeniceX/TCP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VeniceX/TCP/statuses/{sha}","languages_url":"https://api.github.com/repos/VeniceX/TCP/languages","stargazers_url":"https://api.github.com/repos/VeniceX/TCP/stargazers","contributors_url":"https://api.github.com/repos/VeniceX/TCP/contributors","subscribers_url":"https://api.github.com/repos/VeniceX/TCP/subscribers","subscription_url":"https://api.github.com/repos/VeniceX/TCP/subscription","commits_url":"https://api.github.com/repos/VeniceX/TCP/commits{/sha}","git_commits_url":"https://api.github.com/repos/VeniceX/TCP/git/commits{/sha}","comments_url":"https://api.github.com/repos/VeniceX/TCP/comments{/number}","issue_comment_url":"https://api.github.com/repos/VeniceX/TCP/issues/comments{/number}","contents_url":"https://api.github.com/repos/VeniceX/TCP/contents/{+path}","compare_url":"https://api.github.com/repos/VeniceX/TCP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VeniceX/TCP/merges","archive_url":"https://api.github.com/repos/VeniceX/TCP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VeniceX/TCP/downloads","issues_url":"https://api.github.com/repos/VeniceX/TCP/issues{/number}","pulls_url":"https://api.github.com/repos/VeniceX/TCP/pulls{/number}","milestones_url":"https://api.github.com/repos/VeniceX/TCP/milestones{/number}","notifications_url":"https://api.github.com/repos/VeniceX/TCP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VeniceX/TCP/labels{/name}","releases_url":"https://api.github.com/repos/VeniceX/TCP/releases{/id}","deployments_url":"https://api.github.com/repos/VeniceX/TCP/deployments","created_at":"2016-02-15T23:03:28Z","updated_at":"2016-03-27T17:41:09Z","pushed_at":"2016-04-08T06:30:42Z","git_url":"git://github.com/VeniceX/TCP.git","ssh_url":"git@github.com:VeniceX/TCP.git","clone_url":"https://github.com/VeniceX/TCP.git","svn_url":"https://github.com/VeniceX/TCP","homepage":null,"size":73,"stargazers_count":2,"watchers_count":2,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"VeniceX:master","ref":"master","sha":"fc49b96a670be2498566fbaf211fc7d312d3aa09","user":{"login":"VeniceX","id":17913063,"avatar_url":"https://avatars.githubusercontent.com/u/17913063?v=3","gravatar_id":"","url":"https://api.github.com/users/VeniceX","html_url":"https://github.com/VeniceX","followers_url":"https://api.github.com/users/VeniceX/followers","following_url":"https://api.github.com/users/VeniceX/following{/other_user}","gists_url":"https://api.github.com/users/VeniceX/gists{/gist_id}","starred_url":"https://api.github.com/users/VeniceX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VeniceX/subscriptions","organizations_url":"https://api.github.com/users/VeniceX/orgs","repos_url":"https://api.github.com/users/VeniceX/repos","events_url":"https://api.github.com/users/VeniceX/events{/privacy}","received_events_url":"https://api.github.com/users/VeniceX/received_events","type":"Organization","site_admin":false},"repo":{"id":51792099,"name":"TCP","full_name":"VeniceX/TCP","owner":{"login":"VeniceX","id":17913063,"avatar_url":"https://avatars.githubusercontent.com/u/17913063?v=3","gravatar_id":"","url":"https://api.github.com/users/VeniceX","html_url":"https://github.com/VeniceX","followers_url":"https://api.github.com/users/VeniceX/followers","following_url":"https://api.github.com/users/VeniceX/following{/other_user}","gists_url":"https://api.github.com/users/VeniceX/gists{/gist_id}","starred_url":"https://api.github.com/users/VeniceX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VeniceX/subscriptions","organizations_url":"https://api.github.com/users/VeniceX/orgs","repos_url":"https://api.github.com/users/VeniceX/repos","events_url":"https://api.github.com/users/VeniceX/events{/privacy}","received_events_url":"https://api.github.com/users/VeniceX/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VeniceX/TCP","description":"TCP sockets","fork":false,"url":"https://api.github.com/repos/VeniceX/TCP","forks_url":"https://api.github.com/repos/VeniceX/TCP/forks","keys_url":"https://api.github.com/repos/VeniceX/TCP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VeniceX/TCP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VeniceX/TCP/teams","hooks_url":"https://api.github.com/repos/VeniceX/TCP/hooks","issue_events_url":"https://api.github.com/repos/VeniceX/TCP/issues/events{/number}","events_url":"https://api.github.com/repos/VeniceX/TCP/events","assignees_url":"https://api.github.com/repos/VeniceX/TCP/assignees{/user}","branches_url":"https://api.github.com/repos/VeniceX/TCP/branches{/branch}","tags_url":"https://api.github.com/repos/VeniceX/TCP/tags","blobs_url":"https://api.github.com/repos/VeniceX/TCP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VeniceX/TCP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VeniceX/TCP/git/refs{/sha}","trees_url":"https://api.github.com/repos/VeniceX/TCP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VeniceX/TCP/statuses/{sha}","languages_url":"https://api.github.com/repos/VeniceX/TCP/languages","stargazers_url":"https://api.github.com/repos/VeniceX/TCP/stargazers","contributors_url":"https://api.github.com/repos/VeniceX/TCP/contributors","subscribers_url":"https://api.github.com/repos/VeniceX/TCP/subscribers","subscription_url":"https://api.github.com/repos/VeniceX/TCP/subscription","commits_url":"https://api.github.com/repos/VeniceX/TCP/commits{/sha}","git_commits_url":"https://api.github.com/repos/VeniceX/TCP/git/commits{/sha}","comments_url":"https://api.github.com/repos/VeniceX/TCP/comments{/number}","issue_comment_url":"https://api.github.com/repos/VeniceX/TCP/issues/comments{/number}","contents_url":"https://api.github.com/repos/VeniceX/TCP/contents/{+path}","compare_url":"https://api.github.com/repos/VeniceX/TCP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VeniceX/TCP/merges","archive_url":"https://api.github.com/repos/VeniceX/TCP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VeniceX/TCP/downloads","issues_url":"https://api.github.com/repos/VeniceX/TCP/issues{/number}","pulls_url":"https://api.github.com/repos/VeniceX/TCP/pulls{/number}","milestones_url":"https://api.github.com/repos/VeniceX/TCP/milestones{/number}","notifications_url":"https://api.github.com/repos/VeniceX/TCP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VeniceX/TCP/labels{/name}","releases_url":"https://api.github.com/repos/VeniceX/TCP/releases{/id}","deployments_url":"https://api.github.com/repos/VeniceX/TCP/deployments","created_at":"2016-02-15T23:03:28Z","updated_at":"2016-03-27T17:41:09Z","pushed_at":"2016-04-08T06:30:42Z","git_url":"git://github.com/VeniceX/TCP.git","ssh_url":"git@github.com:VeniceX/TCP.git","clone_url":"https://github.com/VeniceX/TCP.git","svn_url":"https://github.com/VeniceX/TCP","homepage":null,"size":73,"stargazers_count":2,"watchers_count":2,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VeniceX/TCP/pulls/2"},"html":{"href":"https://github.com/VeniceX/TCP/pull/2"},"issue":{"href":"https://api.github.com/repos/VeniceX/TCP/issues/2"},"comments":{"href":"https://api.github.com/repos/VeniceX/TCP/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/VeniceX/TCP/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/VeniceX/TCP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VeniceX/TCP/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/VeniceX/TCP/statuses/ab30e1b6627e902824f83c8de984cf1782e15b55"}}}}