{"id":22915009,"url":"https://github.com/stratisproject/tcpserver","last_synced_at":"2025-05-12T13:44:46.341Z","repository":{"id":95902261,"uuid":"97099307","full_name":"stratisproject/TCPServer","owner":"stratisproject","description":"IServer implementation for ASP.NET Core using bare TCP socket at the transport layer","archived":false,"fork":false,"pushed_at":"2018-06-22T15:10:01.000Z","size":42,"stargazers_count":34,"open_issues_count":0,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-04T11:42:36.811Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stratisproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-07-13T08:32:29.000Z","updated_at":"2024-05-08T18:39:59.000Z","dependencies_parsed_at":"2023-03-16T02:32:26.519Z","dependency_job_id":null,"html_url":"https://github.com/stratisproject/TCPServer","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FTCPServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FTCPServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FTCPServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FTCPServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stratisproject","download_url":"https://codeload.github.com/stratisproject/TCPServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253749780,"owners_count":21958190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T05:18:16.081Z","updated_at":"2025-05-12T13:44:46.285Z","avatar_url":"https://github.com/stratisproject.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TCPServer\nIServer implementation for ASP.NET Core using bare TCP socket at the transport layer.\n\nThis has been create to have a minimal HTTP server which does not depends on Kestrel.\n\nKestrel is meant to be a complete HTTP server. This is an incomplete TCP Server using HTTP semantic to reuse HttpClient/ASP.NET Core.\n\nNuget:\n\nThe package is hosted on [nuget](https://www.nuget.org/packages/TCPServer).\n```\ndotnet add package TCPServer\n```\n\nUsage:\n\nCreate and run a server:\n```\nprivate IWebHost CreateHost()\n{\n\tvar host = new WebHostBuilder()\n\t\t.UseStartup\u003cStartup\u003e()\n\t\t.UseTCPServer(new ServerOptions(new IPEndPoint(IPAddress.Parse(\"0.0.0.0\"), 29472)))\n\t\t.Build();\n\thost.Start();\n\treturn host;\n}\n```\n\nHow to call it with HttpClient:\n\n```\nIWebHost host = CreateHost();\nusing(var client = new HttpClient(new TCPHttpMessageHandler()))\n{\n\tvar nico = client.GetAsync(\"http://127.0.0.1:29472/v1/hello/nico\").Result.Content.ReadAsStringAsync().Result;\n\tAssert.Equal(\"\\\"nico\\\"\", nico);\n\tnico = client.GetAsync(\"http://127.0.0.1:29472/v1/hello/nico?test=toto\").Result.Content.ReadAsStringAsync().Result;\n\tAssert.Equal(\"\\\"nicototo\\\"\", nico);\n\n\n\tvar error = Assert.Throws\u003cHttpRequestException\u003e(() =\u003e client.GetAsync(\"http://127.0.0.1:29472/v1/badrequest/nico\").Result.EnsureSuccessStatusCode());\n\tAssert.Contains(\"400\", error.Message);\n\n\tnico = client.PostAsync(\"http://127.0.0.1:29472/v1/hellojson/\", new StringContent(\"{ \\\"Name\\\" : \\\"Nicoo\\\" }\", Encoding.UTF8, \"application/json\")).Result.Content.ReadAsStringAsync().Result;\n\tAssert.Equal(\"\\\"Nicoo\\\"\", nico);\n}\n```\n\nThis is assuming this simple Controller:\n\n```\npublic class MainController : Controller\n{\n\t[HttpGet]\n\t[Route(\"v1/hello/{hello}\")]\n\tpublic IActionResult Hello(string hello, string test)\n\t{\n\t\treturn Json(hello + test);\n\t}\n\n\t[HttpPost]\n\t[Route(\"v1/hellojson\")]\n\tpublic IActionResult HelloJson([FromBody]Request req)\n\t{\n\t\treturn Json(req.Name);\n\t}\n\n\t[HttpPost]\n\t[Route(\"v1/nothing\")]\n\tpublic IActionResult Nothing([FromBody]Request req)\n\t{\n\t\treturn new NoResult();\n\t}\n\n\t[HttpGet]\n\t[Route(\"v1/badrequest/{hello}\")]\n\tpublic IActionResult Bad(string hello)\n\t{\n\t\treturn BadRequest(\"boom\");\n\t}\n\n\t[HttpGet]\n\t[Route(\"v1/timeout\")]\n\tpublic IActionResult Timeout()\n\t{\n\t\tThread.Sleep(10000);\n\t\treturn BadRequest(\"boom\");\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstratisproject%2Ftcpserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstratisproject%2Ftcpserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstratisproject%2Ftcpserver/lists"}