Author

Topic: How do bitcoin nodes/miners use the same ports? (Read 109 times)

legendary
Activity: 4522
Merit: 3426
How do bitcoin nodes/miners communicate with each other using the same port? Any ideas on how to fix this?

The port is only used to listen for connection requests.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
This shouldn't be an issue if you are running client and server on different machines. If you want to test something on the same machine, maybe you can configure one of your nodes to listen on one interface like an address on your 192.168 private subnet, and another to listen on localhost on another address in the subnet

The trick is to not bind to 0.0.0.0 (represents all of the interfaces).
staff
Activity: 3458
Merit: 6793
Just writing some code
It's just standard network software code. There's nothing special about Bitcoin or P2P software in this regard. It just combines client side software with server side software. Of course it requires having multiple threads/processes, but you should already be doing that for server side software anyways.

As with any client software, outgoing connections are made with random ports assigned by the operating system. Using standard system calls, a TCP connection will be opened by the OS using whatever port the OS decides. It works in the same way any software would to make connections to a server.

As with any server software, incoming connections are handled using standard system calls (such as accept, poll, select, etc.) and then passed off to other threads for processing. It works in the same way that any server software does to accept incoming connections.
newbie
Activity: 1
Merit: 0
Hello bitcointalk forum,

Quick question, as im trying to build a p2p decentralized network (just a chatroom network), i came across an issue:

When Nodes communicate with each other, they use the same ports, nodes in this network act as a client and a server (They connect to another node and listen to other connections).
The issue that I came across is that, 1 port can only be used to connect and since this port is used, i cant listen to other connections in this port.

How do bitcoin nodes/miners communicate with each other using the same port? Any ideas on how to fix this?
Jump to: