{"id":13626555,"url":"https://github.com/ikskuh/zig-network","last_synced_at":"2025-05-15T10:02:56.215Z","repository":{"id":43120583,"uuid":"259619939","full_name":"ikskuh/zig-network","owner":"ikskuh","description":"A smallest-common-subset of socket functions for crossplatform networking, TCP \u0026 UDP","archived":false,"fork":false,"pushed_at":"2025-02-27T20:30:09.000Z","size":287,"stargazers_count":544,"open_issues_count":11,"forks_count":67,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-14T16:54:11.060Z","etag":null,"topics":["networking","tcp","tcp-client","tcp-server","udp","zig","zig-package"],"latest_commit_sha":null,"homepage":null,"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/ikskuh.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},"funding":{"github":"MasterQ32"}},"created_at":"2020-04-28T11:39:38.000Z","updated_at":"2025-04-08T01:56:25.000Z","dependencies_parsed_at":"2023-01-31T05:45:46.991Z","dependency_job_id":"48b41154-3904-4413-83f8-5356a94f1905","html_url":"https://github.com/ikskuh/zig-network","commit_stats":null,"previous_names":["ikskuh/zig-network"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikskuh","download_url":"https://codeload.github.com/ikskuh/zig-network/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"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":["networking","tcp","tcp-client","tcp-server","udp","zig","zig-package"],"created_at":"2024-08-01T21:02:23.714Z","updated_at":"2025-05-15T10:02:54.415Z","avatar_url":"https://github.com/ikskuh.png","language":"Zig","readme":"# Zig Network Abstraction\n\nSmall network abstraction layer around TCP \u0026 UDP.\n\n## Features\n- Implements the minimal API surface for basic networking\n- Makes cross-platform abstractions\n- Supports blocking and non-blocking I/O via `select`/`poll`\n- UDP multicast support\n\n## Usage\n\n### Use with the package manager\n\n`build.zig.zon`:\n```zig\n.{\n    .name = \"appname\",\n    .version = \"0.0.0\",\n    .dependencies = .{\n        .network = .{\n            .url = \"https://github.com/MasterQ32/zig-network/archive/\u003cCOMMIT_HASH_HERE\u003e.tar.gz\",\n            .hash = \"HASH_GOES_HERE\",\n        },\n    },\n}\n```\n(To aquire the hash, please remove the line containing `.hash`, the compiler will then tell you which line to put back)\n\n`build.zig`:\n```zig\nexe.addModule(\"network\", b.dependency(\"network\", .{}).module(\"network\"));\n```\n\n### Usage example\n\n```zig\nconst network = @import(\"network\");\n\ntest \"Connect to an echo server\" {\n    try network.init();\n    defer network.deinit();\n\n    const sock = try network.connectToHost(std.heap.page_allocator, \"tcpbin.com\", 4242, .tcp);\n    defer sock.close();\n\n    const msg = \"Hi from socket!\\n\";\n    try sock.writer().writeAll(msg);\n\n    var buf: [128]u8 = undefined;\n    std.debug.print(\"Echo: {}\", .{buf[0..try sock.reader().readAll(buf[0..msg.len])]});\n}\n```\n\nSee [async.zig](examples/async.zig) for a more complete example on how to use asynchronous I/O to make a small TCP server.\n\n## Run examples\n\nBuild all examples:\n\n```bash\n$ zig build examples\n```\n\nBuild a specific example:\n\n```bash\n$ zig build sync-examples\n```\n\nTo test an example, eg. `echo`:\n\n```bash\n$ ./zig-out/bin/echo 3000\n``` \n\nin another terminal\n\n```bash\n$ nc localhost 3000\nhello\nhello\nhow are you\nhow are you\n```\n\n## Notes\nOn Windows receive and send function calls are asynchronous and cooperate with the standard library event loop\nwhen `io_mode = .evented` is set in the root file of your program.  \nOther calls (connect, listen, accept etc) are blocking.  \n","funding_links":["https://github.com/sponsors/MasterQ32"],"categories":["Zig"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikskuh%2Fzig-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikskuh%2Fzig-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikskuh%2Fzig-network/lists"}