libp2p-tcp
Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces
Last updated 7 years ago by daviddias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install libp2p-tcp 
SYNC missed versions from official npm registry.

js-libp2p-tcp

Discourse posts Dependency Status js-standard-style

JavaScript implementation of the TCP module for libp2p. It exposes the interface-transport for dial/listen. libp2p-tcp is a very thin shim that adds support for dialing to a multiaddr. This small shim will enable libp2p to use other transports.

Lead Maintainer

Jacob Heun

Table of Contents

Install

npm

> npm install libp2p-tcp

Usage

const TCP = require('libp2p-tcp')
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')

// A simple upgrader that just returns the MultiaddrConnection
const upgrader = {
  upgradeInbound: maConn => maConn,
  upgradeOutbound: maConn => maConn
}

const tcp = new TCP({ upgrader })

const listener = tcp.createListener((socket) => {
  console.log('new connection opened')
  pipe(
    ['hello'],
    socket
  )
})

const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
await listener.listen(addr)
console.log('listening')

const socket = await tcp.dial(addr)
const values = await pipe(
  socket,
  collect
)
console.log(`Value: ${values.toString()}`)

// Close connection after reading
await listener.close()

Outputs:

listening
new connection opened
Value: hello

API

Transport

libp2p-tcp accepts TCP addresses as both IPFS and non IPFS encapsulated addresses, i.e:

/ip4/127.0.0.1/tcp/4001 /ip4/127.0.0.1/tcp/4001/ipfs/QmHash

(both for dialing and listening)

Connection

Contribute

Contributions are welcome! The libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:

Please be aware that all interactions related to libp2p are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2015-2016 David Dias

Current Tags

  • 0.15.1                                ...           beta (4 years ago)
  • 0.17.2                                ...           latest (3 years ago)

57 Versions

  • 0.17.2                                ...           3 years ago
  • 0.17.1                                ...           3 years ago
  • 0.17.0                                ...           3 years ago
  • 0.16.0                                ...           3 years ago
  • 0.15.4                                ...           4 years ago
  • 0.15.3                                ...           4 years ago
  • 0.15.2                                ...           4 years ago
  • 0.15.1                                ...           4 years ago
  • 0.15.0                                ...           4 years ago
  • 0.14.6                                ...           4 years ago
  • 0.14.5                                ...           5 years ago
  • 0.14.4                                ...           5 years ago
  • 0.14.3                                ...           5 years ago
  • 0.14.2                                ...           5 years ago
  • 0.13.2                                ...           5 years ago
  • 0.14.1                                ...           5 years ago
  • 0.14.0                                ...           5 years ago
  • 0.13.1                                ...           5 years ago
  • 0.13.0                                ...           6 years ago
  • 0.12.1                                ...           6 years ago
  • 0.12.0                                ...           7 years ago
  • 0.11.6                                ...           7 years ago
  • 0.11.5                                ...           7 years ago
  • 0.11.4                                ...           7 years ago
  • 0.11.3                                ...           7 years ago
  • 0.11.2                                ...           7 years ago
  • 0.11.1                                ...           7 years ago
  • 0.11.0                                ...           7 years ago
  • 0.10.2                                ...           7 years ago
  • 0.10.1                                ...           8 years ago
  • 0.10.0                                ...           8 years ago
  • 0.9.4                                ...           8 years ago
  • 0.9.3                                ...           8 years ago
  • 0.9.2                                ...           8 years ago
  • 0.9.1                                ...           8 years ago
  • 0.9.0                                ...           8 years ago
  • 0.8.1                                ...           8 years ago
  • 0.8.0                                ...           8 years ago
  • 0.7.4                                ...           8 years ago
  • 0.7.3                                ...           8 years ago
  • 0.7.2                                ...           8 years ago
  • 0.7.1                                ...           8 years ago
  • 0.7.0                                ...           8 years ago
  • 0.6.2                                ...           8 years ago
  • 0.6.1                                ...           8 years ago
  • 0.6.0                                ...           8 years ago
  • 0.5.3                                ...           8 years ago
  • 0.5.2                                ...           9 years ago
  • 0.5.1                                ...           9 years ago
  • 0.5.0                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (7)

© 2010 - cnpmjs.org x YWFE | Home | YWFE