You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 11, 2020. It is now read-only.
Before creating a connection from a transport compatible with `libp2p` it is important to understand some concepts:
43
+
44
+
-**socket**: the underlying raw duplex connection between two nodes. It is created by the transports during a dial/listen.
45
+
-**connection**: the abstract libp2p duplex connection between two nodes. The transport must pipe the `socket` through the connection.
46
+
-**stream**: a single duplex channel of the `connection`. Each connection may have many streams.
47
+
48
+
A connection stands for the libp2p communication duplex layer between two nodes. It is **not** the underlying raw transport duplex layer (socket), such as a TCP socket, but an abstracted duplex layer that sits on top of the raw socket.
49
+
50
+
When a libp2p transport creates its socket, a new `connection` instance should be created and the transport should **pipe** both input and output of the socket through this `connection`, i.e. `pipe(socket, connection, socket)`.
51
+
52
+
The transport must handle the translation of cleanup from the socket to the connection. That is, the errors, resets or closes on the socket **must** be passed to the connection. In the same way, the transport **must** map these actions from the `connection` to the socket. This helps ensuring that the transport is responsible for socket management, while also allowing the application layer to handle the connection management.
@@ -147,7 +188,7 @@ This property contains the remote peer info of this connection.
147
188
148
189
-`JavaScript` - `conn.status`
149
190
150
-
This property contains the status of the connection. It can be either `OPEN`, `CLOSED` or `CLOSING`. Once the creating is created it is in an `OPEN` status. When a `conn.close()` happens, the status will change to `CLOSING` and finally, after all the connection streams are properly closed, the status will be `CLOSED`.
191
+
This property contains the status of the connection. It can be either `OPEN`, `CLOSED` or `CLOSING`. Once the connection is created it is in an `OPEN` status. When a `conn.close()` happens, the status will change to `CLOSING` and finally, after all the connection streams are properly closed, the status will be `CLOSED`.
0 commit comments