This repo is [gomod](https://github.com/golang/go/wiki/Modules)-compatible, and users of
go 1.11 and later with modules enabled will automatically pull the latest tagged release
by referencing this package. Upgrades to future releases can be managed using `go get`,
or by editing your `go.mod` file as [described by the gomod documentation](https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies).
## Usage
TCP is one of the default transports enabled when constructing a standard libp2p
Host, along with [WebSockets](https://github.com/libp2p/go-ws-transport).
Calling [`libp2p.New`][godoc-libp2p-new] to construct a libp2p Host will enable
the TCP transport, unless you override the default transports by passing in
`Options` to `libp2p.New`.
To explicitly enable the TCP transport while constructing a host, use the
`libp2p.Transport` option, passing in the `NewTCPTransport` constructor function:
``` go
import (
"context"
libp2p "github.com/libp2p/go-libp2p"
tcp "github.com/libp2p/go-tcp-transport"
)
ctx := context.Background()
// TCP only:
h, err := libp2p.New(ctx,
libp2p.Transport(tcp.NewTCPTransport)
)
```
The example above will replace the default transports with a single TCP
transport. To add multiple tranports, use `ChainOptions`:
``` go
// TCP and QUIC:
h, err := libp2p.New(ctx,
libp2p.ChainOptions(
libp2p.Transport(tcp.NewTCPTransport),
libp2p.Transport(quic.NewTransport)) // see https://github.com/libp2p/go-libp2p-quic-transport
)
```
## Addresses
The TCP transport supports [multiaddrs][multiaddr] that contain a `tcp`
component, provided that there is sufficient addressing information for the IP