{"id":13482558,"url":"https://github.com/libp2p/js-libp2p-tcp","last_synced_at":"2025-03-27T13:32:04.412Z","repository":{"id":1370422,"uuid":"42521859","full_name":"libp2p/js-libp2p-tcp","owner":"libp2p","description":"JavaScript implementation of the TCP module that libp2p uses that implements the interface-transport spec","archived":true,"fork":false,"pushed_at":"2023-07-21T15:48:33.000Z","size":1864,"stargazers_count":76,"open_issues_count":2,"forks_count":40,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-08-12T21:27:47.723Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://libp2p.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libp2p.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-09-15T13:42:08.000Z","updated_at":"2023-10-06T20:45:56.000Z","dependencies_parsed_at":"2024-06-18T13:41:24.855Z","dependency_job_id":null,"html_url":"https://github.com/libp2p/js-libp2p-tcp","commit_stats":{"total_commits":371,"total_committers":38,"mean_commits":9.763157894736842,"dds":0.6873315363881402,"last_synced_commit":"e82c753a282a56fe852cbea7783222bf6b79eeb9"},"previous_names":["diasdavid/node-libp2p-tcp"],"tags_count":114,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-libp2p-tcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-libp2p-tcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-libp2p-tcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-libp2p-tcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libp2p","download_url":"https://codeload.github.com/libp2p/js-libp2p-tcp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791922,"owners_count":20672666,"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":[],"created_at":"2024-07-31T17:01:03.208Z","updated_at":"2025-03-27T13:32:04.061Z","avatar_url":"https://github.com/libp2p.png","language":"TypeScript","funding_links":[],"categories":["Modules"],"sub_categories":[],"readme":"# 📁 Archived - this module has been merged into [js-libp2p](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-tcp)\n\n# @libp2p/tcp \u003c!-- omit in toc --\u003e\n\n[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)\n[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-tcp.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-tcp)\n[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-tcp/js-test-and-release.yml?branch=master\\\u0026style=flat-square)](https://github.com/libp2p/js-libp2p-tcp/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)\n\n\u003e A TCP transport for libp2p\n\n## Table of contents \u003c!-- omit in toc --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n- [API Docs](#api-docs)\n- [License](#license)\n- [Contribution](#contribution)\n\n## Install\n\n```console\n$ npm i @libp2p/tcp\n```\n\n## Usage\n\n```js\nimport { tcp } from '@libp2p/tcp'\nimport { multiaddr } from '@multiformats/multiaddr'\nimport { pipe } from 'it-pipe'\nimport all from 'it-all'\n\n// A simple upgrader that just returns the MultiaddrConnection\nconst upgrader = {\n  upgradeInbound: async maConn =\u003e maConn,\n  upgradeOutbound: async maConn =\u003e maConn\n}\n\nconst transport = tcp()()\n\nconst listener = transport.createListener({\n  upgrader,\n  handler: (socket) =\u003e {\n    console.log('new connection opened')\n    pipe(\n      ['hello', ' ', 'World!'],\n      socket\n    )\n  }\n})\n\nconst addr = multiaddr('/ip4/127.0.0.1/tcp/9090')\nawait listener.listen(addr)\nconsole.log('listening')\n\nconst socket = await transport.dial(addr, { upgrader })\nconst values = await pipe(\n  socket,\n  all\n)\nconsole.log(`Value: ${values.toString()}`)\n\n// Close connection after reading\nawait listener.close()\n```\n\nOutputs:\n\n```sh\nlistening\nnew connection opened\nValue: hello World!\n```\n\n## API Docs\n\n- \u003chttps://libp2p.github.io/js-libp2p-tcp\u003e\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / \u003chttp://opensource.org/licenses/MIT\u003e)\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fjs-libp2p-tcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibp2p%2Fjs-libp2p-tcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fjs-libp2p-tcp/lists"}