{"id":13712533,"url":"https://github.com/nikneym/ws","last_synced_at":"2025-07-29T12:32:33.179Z","repository":{"id":159772412,"uuid":"569795626","full_name":"nikneym/ws","owner":"nikneym","description":"WebSocket library for Zig ⚡","archived":false,"fork":false,"pushed_at":"2024-02-22T22:21:26.000Z","size":278,"stargazers_count":64,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T03:28:43.557Z","etag":null,"topics":["websocket","websockets","ws","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/nikneym.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-23T16:22:22.000Z","updated_at":"2025-03-11T08:32:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"109e77e3-11b3-4953-a409-7b6609f06d11","html_url":"https://github.com/nikneym/ws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nikneym/ws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikneym%2Fws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikneym%2Fws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikneym%2Fws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikneym%2Fws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikneym","download_url":"https://codeload.github.com/nikneym/ws/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikneym%2Fws/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267686523,"owners_count":24127716,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["websocket","websockets","ws","zig","ziglang"],"created_at":"2024-08-02T23:01:19.513Z","updated_at":"2025-07-29T12:32:33.152Z","avatar_url":"https://github.com/nikneym.png","language":"Zig","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/nikneym/ws/blob/main/misc/logo.png\" alt=\"ws\" width=\"60%\" height=\"30%\" /\u003e\n\u003c/p\u003e\n\nws\n===========\na lightweight WebSocket library for Zig ⚡\n\nFeatures\n===========\n* Only allocates for WebSocket handshake, message parsing and building does not allocate\n* Ease of use, can be used directly with `net.Stream`\n* Does buffered reads and writes (can be used with any other reader/writer too)\n* Supports streaming output thanks to WebSocket fragmentation\n\nExample\n===========\nBy default, ws uses the `Stream` interface of `net` namespace.\nYou can use your choice of stream through `ws.Client` interface.\n```zig\ntest \"Simple connection to :8080\" {\n    const allocator = std.testing.allocator;\n\n    var cli = try connect(allocator, try std.Uri.parse(\"ws://localhost:8080\"), \u0026.{\n        .{\"Host\",   \"localhost\"},\n        .{\"Origin\", \"http://localhost/\"},\n    });\n    defer cli.deinit(allocator);\n\n    while (true) {\n        const msg = try cli.receive();\n        switch (msg.type) {\n            .text =\u003e {\n                std.debug.print(\"received: {s}\\n\", .{msg.data});\n                try cli.send(.text, msg.data);\n            },\n\n            .ping =\u003e {\n                std.debug.print(\"got ping! sending pong...\\n\", .{});\n                try cli.pong();\n            },\n\n            .close =\u003e {\n                std.debug.print(\"close\", .{});\n                break;\n            },\n\n            else =\u003e {\n                std.debug.print(\"got {s}: {s}\\n\", .{@tagName(msg.type), msg.data});\n            },\n        }\n    }\n\n    try cli.close();\n}\n```\n\nPlanned\n===========\n- [ ] WebSocket server support\n- [ ] TLS support out of the box (tracks `std.crypto.tls.Client`)\n- [x] Request \u0026 response headers\n- [ ] WebSocket Compression support\n\nAcknowledgements\n===========\nThis library wouldn't be possible without these cool projects \u0026 posts:\n* [truemedian/wz](https://github.com/truemedian/wz)\n* [frmdstryr/zhp](https://github.com/frmdstryr/zhp/blob/master/src/websocket.zig)\n* [treeform/ws](https://github.com/treeform/ws)\n* [openmymind.net/WebSocket-Framing-Masking-Fragmentation-and-More](https://www.openmymind.net/WebSocket-Framing-Masking-Fragmentation-and-More/)\n* [Writing WebSocket servers](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers)\n\nLicense\n===========\nMIT License, [check out](https://github.com/nikneym/ws/blob/main/LICENSE).\n","funding_links":[],"categories":["Network \u0026 Web"],"sub_categories":["Web Framework"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikneym%2Fws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikneym%2Fws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikneym%2Fws/lists"}