{"id":21456000,"url":"https://github.com/sntran/deno_socket","last_synced_at":"2026-05-08T14:04:21.255Z","repository":{"id":213857050,"uuid":"734772378","full_name":"sntran/deno_socket","owner":"sntran","description":"A Deno Implementation of the Cloudflare Socket API","archived":false,"fork":false,"pushed_at":"2024-04-29T16:20:50.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-07T11:45:23.329Z","etag":null,"topics":["cloudflare","deno","sockets","wintercg","workers"],"latest_commit_sha":null,"homepage":"https://deno.land/x/socket","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sntran.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":"2023-12-22T15:18:19.000Z","updated_at":"2024-04-29T16:20:54.000Z","dependencies_parsed_at":"2023-12-26T02:23:58.707Z","dependency_job_id":"ed29f800-e861-4c00-a6d4-3976945bd737","html_url":"https://github.com/sntran/deno_socket","commit_stats":null,"previous_names":["sntran/deno_socket"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sntran/deno_socket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sntran%2Fdeno_socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sntran%2Fdeno_socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sntran%2Fdeno_socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sntran%2Fdeno_socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sntran","download_url":"https://codeload.github.com/sntran/deno_socket/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sntran%2Fdeno_socket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722757,"owners_count":26034463,"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-10-07T02:00:06.786Z","response_time":59,"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":["cloudflare","deno","sockets","wintercg","workers"],"created_at":"2024-11-23T05:14:13.210Z","updated_at":"2025-10-07T05:23:08.805Z","avatar_url":"https://github.com/sntran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deno_socket\n\nA Deno Implementation of the Cloudflare Socket API\n\nDeno already has great support for TCP, but since Cloudflare proposed a \n[WinterCG spec](https://sockets-api.proposal.wintercg.org/), this provides the\nsame interface for Deno so we could migrate easier later on. \n\nInspired by `@arrowood.dev/socket`, but with Deno's runtime APIs.\n\n## Usage\n\n```js\nimport { connect } from \"https://deno.land/x/socket/mod.js\";\n\nexport default {\n  async fetch(request) {\n    const gopherAddr = { hostname: \"gopher.floodgap.com\", port: 70 };\n    const url = new URL(req.url);\n\n    try {\n      const socket = connect(gopherAddr);\n\n      const writer = socket.writable.getWriter()\n      const encoder = new TextEncoder();\n      const encoded = encoder.encode(url.pathname + \"\\r\\n\");\n      await writer.write(encoded);\n\n      return new Response(socket.readable, { headers: { \"Content-Type\": \"text/plain\" } });\n    } catch (error) {\n      return new Response(\"Socket connection failed: \" + error, { status: 500 });\n    }\n  }\n};\n```\n\nThe module can also be run as a simple CLI to send a message to a TCP server,\nsimilar to the example above, but send response to `stdout`.\n\nFor example:\n\n```shell\n$ deno run --allow-net mod.js gopher.floodgap.com:70 /\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsntran%2Fdeno_socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsntran%2Fdeno_socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsntran%2Fdeno_socket/lists"}