{"id":17007528,"url":"https://github.com/wkhallen/jdtp","last_synced_at":"2025-03-22T11:47:04.208Z","repository":{"id":49352278,"uuid":"517451976","full_name":"WKHAllen/JDTP","owner":"WKHAllen","description":"Modern networking interfaces for Java.","archived":false,"fork":false,"pushed_at":"2023-01-22T01:20:10.000Z","size":131,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T11:22:43.468Z","etag":null,"topics":["java","networking","socket","socket-client","socket-server"],"latest_commit_sha":null,"homepage":"https://wkhallen.com/dtp","language":"Java","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-07-24T22:36:57.000Z","updated_at":"2022-09-01T17:59:34.000Z","dependencies_parsed_at":"2023-02-12T12:31:37.575Z","dependency_job_id":null,"html_url":"https://github.com/WKHAllen/JDTP","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FJDTP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FJDTP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FJDTP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2FJDTP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WKHAllen","download_url":"https://codeload.github.com/WKHAllen/JDTP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244952785,"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":["java","networking","socket","socket-client","socket-server"],"created_at":"2024-10-14T05:26:02.050Z","updated_at":"2025-03-22T11:47:04.170Z","avatar_url":"https://github.com/WKHAllen.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Transfer Protocol for Java\n\nModern networking interfaces for Java.\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## Creating a server\n\nA server can be built using the `Server` implementation:\n\n```java\nimport jdtp.Server;\n\n// Create a server that receives strings and returns the length of each string\nclass MyServer extends Server {\n    @Override\n    protected void receive(long clientID, Object data) {\n        // Send back the length of the string\n        String message = (String) data;\n        send(clientID, message.length());\n    }\n\n    @Override\n    protected void connect(long clientID) {\n        System.out.printf(\"Client with ID %d connected\\n\", clientID);\n    }\n\n    @Override\n    protected void disconnect(long clientID) {\n        System.out.printf(\"Client with ID %d disconnected\\n\", clientID);\n    }\n}\n\nclass Main {\n    public static void main(String[] args) {\n        // Start the server\n        MyServer 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```java\nimport jdtp.Client;\n\n// Create a client that sends a message to the server and receives the length of the message\nclass MyClient extends Client {\n    private final String message;\n\n    MyClient(String message) {\n        this.message = message;\n    }\n\n    @Override\n    protected void receive(Object data) {\n        // Validate the response\n        int intData = (int) data;\n        System.out.printf(\"Received response from server: %d\\n\", intData);\n        assert intData == message.length();\n    }\n\n    @Override\n    protected void disconnected() {\n        System.err.println(\"Unexpectedly disconnected from server\");\n    }\n}\n\nclass Main {\n    public static void main(String[] args) {\n        // Connect to the server\n        String message = \"Hello, server!\";\n        MyClient 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## Serialization\n\nThe protocol is able to serialize and deserialize primitive types. Custom types can be used, though they will need to\nimplement the [`Serializable`](https://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html) interface.\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 4096-bit RSA key-pair.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhallen%2Fjdtp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwkhallen%2Fjdtp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhallen%2Fjdtp/lists"}