5

When client A opens a connection to client B, it opens its TCP connection to second client's port 8333. Is this connection solely used for A's queries and B's answers to A's query, or can B also query A using the same connection?

For example, A can ask B for list of known peers using this connection, but can B ask A for the same using the connection A established, or does B need to open a new connection to A's port 8333, exchange version messages, and only then send its queries?

2

I changed wording of the quote a bit, so it would match your question.

When you connect to a client, you will receive responses on the port you just used to connect to that client. The Bitcoin network uses persistent TCP connections that remain active so long as both nodes continue running.

Bitcoin communication with non-standard ports

For the sake of discussion we can define Server as the side that waits or listens on port 8333 and Client as the side that initiates connection by sending network packet to "server_ip_address":"8333" , the network packet has address of the Client, so Server can send reply back to "client_ip_address":"any_port_reserved_for_client_on_client's_network" .

Bitcoin always reserves 8333 port on workstation to communicate with Bitcoin Network, but usually home router changes the port number in packet when it's on it's way out for the Network Address Translation mechanic (NAT). To overcome NAT and make Bitcoin Client act as Server and accept incoming connections, Port Forwarding or UPnP should be enabled.

  • So you only receive responses to your queries, and you shouldn't expect other clients to send you their queries to port other than 8333? – ThePiachu Nov 4 '11 at 10:19
  • I edited my answer to clarify things. – Serith Nov 4 '11 at 11:50
  • I don't think you're answering the question that was asked. He's asking whether it matters who listens and who connects. It doesn't, as Gavin's answer says. Once a connection is made, both sides can send requests and responses through that connection. Also, Bitcoin doesn't always reserve port 8333; it's configurable by the user with the -port=<port> command line argument. – Chris Moore Feb 26 '12 at 19:27
6

Once the connection is established, the communication is completely symmetric-- either end can ask the other anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.