<p>You're pretty close, with the deviations being I think primarily in terminology.</p>

<p>Client A <em>listens</em> for connections on port 8333. <em>Listening</em> is a <em>server</em> activity.</p>

<p>Client A chooses an <a href="https://en.wikipedia.org/wiki/Ephemeral_port" rel="nofollow">ephemeral port</a> and opens a connection to the address of Client B on port 8333, on which Client B is <em>listening</em>. At the TCP level, there is a <a href="http://www.inetdaemon.com/tutorials/internet/tcp/3-way_handshake.shtml" rel="nofollow">three-way handshake</a> to establish the connection. Imagine this connection as a bi-directional pipe to and from which both clients can read and write.</p>

<p>Once established, Client A sends <code>Version</code> and Client B receives it. Client B sends <code>Version</code> and Client A receives it. Client A sends <code>Verack</code> and I think Client B also sends <code>Verack</code>, which is an acknowledgement of the version compatibility or receipt.</p>

<p>This is my understanding.</p>

CC BY-SA 3.0
2012-11-24T05:00:23.963Z
2012-11-24T05:00:23.963Z
Colin Dean
<p>I'm trying to understand how exactly does the Bitcoin client communicate initially with another client, as I'm making my own client and learning new things about TCP protocol. As I understand, the Bitcoin client uses the standard port (8333) as a server port that is listening to other clients' communication, and the client opens up new ports as it is trying to communicate with other clients. As I'm not sure if I understand the communication correctly, I made this chart:</p>

<p><img src="https://docs.google.com/drawings/pub?id=1Vj0sjmZqbQy97JShB1DUcEXpDiH7djdLsGFxXGFWp3E&amp;w=960&amp;h=720"></p>

<p>My question is: is this diagram and my assumptions correct, or did I make some mistake in understanding how the protocol works?</p>

CC BY-SA 3.0
2011-11-02T22:57:45.203Z
Since this is TCP, it's probably clearer to simply state that A opens a TCP connection to B's port 8333 and that this connection is used for subsequent communication between them.
David Schwartz
<client><protocol><bitcoin-core><tcp>
Bitcoin initial communication diagram
ThePiachu
# Bitcoin initial communication diagram

(Asked by: username_0 on 2011-11-02)

I'm trying to understand how exactly does the Bitcoin client communicate initially with another client, as I'm making my own client and learning new things about TCP protocol. As I understand, the Bitcoin client uses the standard port (8333) as a server port that is listening to other clients' communication, and the client opens up new ports as it is trying to communicate with other clients. As I'm not sure if I understand the communication correctly, I made this chart:

![](https://docs.google.com/drawings/pub?id=1Vj0sjmZqbQy97JShB1DUcEXpDiH7djdLsGFxXGFWp3E&w=960&h=720)

My question is: is this diagram and my assumptions correct, or did I make some mistake in understanding how the protocol works?

**Tags:** client, protocol, bitcoin-core, tcp

> **Comments:**
> **username_1**: Since this is TCP, it's probably clearer to simply state that A opens a TCP connection to B's port 8333 and that this connection is used for subsequent communication between them.  

---

## 1 answers

### Answer by username_2 on 2012-11-24. Score: 2 | Accepted answer

You're pretty close, with the deviations being I think primarily in terminology.

Client A *listens* for connections on port 8333. *Listening* is a *server* activity.

Client A chooses an [ephemeral port](https://en.wikipedia.org/wiki/Ephemeral_port) and opens a connection to the address of Client B on port 8333, on which Client B is *listening*. At the TCP level, there is a [three-way handshake](http://www.inetdaemon.com/tutorials/internet/tcp/3-way_handshake.shtml) to establish the connection. Imagine this connection as a bi-directional pipe to and from which both clients can read and write.

Once established, Client A sends `Version` and Client B receives it. Client B sends `Version` and Client A receives it. Client A sends `Verack` and I think Client B also sends `Verack`, which is an acknowledgement of the version compatibility or receipt.

This is my understanding.


---

