{"id":17007537,"url":"https://github.com/wkhallen/csdtp","last_synced_at":"2025-10-07T16:08:32.285Z","repository":{"id":65404980,"uuid":"485131973","full_name":"WKHAllen/CSDTP","owner":"WKHAllen","description":"Modern networking interfaces for C#.","archived":false,"fork":false,"pushed_at":"2023-01-22T01:19:38.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T11:22:46.261Z","etag":null,"topics":["csharp","networking","socket","socket-client","socket-server"],"latest_commit_sha":null,"homepage":"https://wkhallen.com/dtp","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/WKHAllen.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}},"created_at":"2022-04-24T20:24:32.000Z","updated_at":"2022-10-14T00:22:05.000Z","dependencies_parsed_at":"2023-02-12T12:16:08.856Z","dependency_job_id":null,"html_url":"https://github.com/WKHAllen/CSDTP","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FCSDTP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FCSDTP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FCSDTP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FCSDTP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WKHAllen","download_url":"https://codeload.github.com/WKHAllen/CSDTP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244952780,"owners_count":20537472,"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":["csharp","networking","socket","socket-client","socket-server"],"created_at":"2024-10-14T05:26:03.901Z","updated_at":"2025-10-07T16:08:32.197Z","avatar_url":"https://github.com/WKHAllen.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Transfer Protocol for C#\n\nModern networking interfaces for C#.\n\n## Data Transfer Protocol\n\nThe Data Transfer Protocol (DTP) is a larger project to make ergonomic network programming available in any language.\nSee the full project [here](https://wkhallen.com/dtp/).\n\n## Installation\n\nInstall the package:\n\n```sh\n$ nuget install CSDTP\n```\n\n## Creating a server\n\nA server can be built using the `Server` implementation:\n\n```csharp\nusing CSDTP;\n\n// Create a server that receives strings and returns the length of each string\npublic class MyServer : Server\u003cint, string\u003e\n{\n    protected override void Receive(ulong clientId, string data)\n    {\n        // Send back the length of the string\n        Send(clientId, data.Length);\n    }\n\n    protected override void Connect(ulong clientId)\n    {\n        Console.WriteLine(\"Client with ID {0} connected\", clientId);\n    }\n\n    protected override void Disconnect(ulong clientId)\n    {\n        Console.WriteLine(\"Client with ID {0} disconnected\", clientId);\n    }\n}\n\npublic class Main\n{\n    public static void Main()\n    {\n        // Start the server\n        var server = new MyServer();\n        server.Start(\"127.0.0.1\", 29275);\n    }\n}\n```\n\n## Creating a client\n\nA client can be built using the `Client` implementation:\n\n```csharp\nusing CSDTP;\n\n// Create a client that sends a message to the server and receives the length of the message\npublic class MyClient : Client\u003cstring, int\u003e\n{\n    private readonly string _message;\n\n    public MyClient(string message)\n    {\n        _message = message;\n    }\n\n    protected override void Receive(int data)\n    {\n        // Validate the response\n        Console.WriteLine(\"Received response from server: {0}\", data);\n        Assert.AreEqual(data, _message.Length);\n    }\n\n    protected override void Disconnected()\n    {\n        Console.WriteLine(\"Unexpectedly disconnected from server\");\n    }\n}\n\npublic class Main\n{\n    public static void Main()\n    {\n        // Connect to the server\n        var message = \"Hello, server!\";\n        var client = new MyClient(message);\n        client.Connect(\"127.0.0.1\", 29275);\n\n        // Send a message to the server\n        client.Send(message);\n    }\n}\n```\n\n## Security\n\nInformation security comes included. Every message sent over a network interface is encrypted with AES-256. Key\nexchanges are performed using a 2048-bit RSA key-pair.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhallen%2Fcsdtp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwkhallen%2Fcsdtp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhallen%2Fcsdtp/lists"}