Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Peers address #3

Closed
florianjs opened this issue Apr 13, 2020 · 1 comment
Closed

[QUESTION] Peers address #3

florianjs opened this issue Apr 13, 2020 · 1 comment

Comments

@florianjs
Copy link

Hello,

How are generated peers address?

For example, with https://github.com/v-braun/go2p/blob/master/example_test.go
If I run a server at 127.0.0.1:7071 and another one at 127.0.0.1:7072 for example and I connect it to the first one, the peer address change to something like 127.0.0.1:30002

Probably a stupid question, but I'm a Junior (especially in P2P ... )
Thanks :)

@florianjs florianjs changed the title [QUESTION] [QUESTION] Peers address Apr 13, 2020
@v-braun
Copy link
Owner

v-braun commented Sep 21, 2020

Hi!
This is a common assumption but it is not correct 😃

TCP Communication has alway a Server and a Client part.
The Server that u are starting "listening" to an endpoint and the client "dials" to this endpoint.
In this Lib (basically in all P2P scenarios) each node in the Network us min. one Server (wich is used to listen to inbound connections) and multiple clients (to connect to other nodes).

Wich means:
1.: You start a (Application-1) Server with the address 127.0.0.1:7071
2.: Than you start another (Application-2) Server with the address 127.0.0.1:7072

Run the netstat command and you should see two applications running and LISTENING to the above ports.

3.: You create a connection from Application-1 to Application-2, wich means that Application-1 use a client and dials to the Server of Application-2.
During the Dial procedure the "client" of Application-1 will open a new port (30002) wich is assigned by the operating system.

Run the netstat command and you should see still the two LISTENING ports and you should see that there is an ESTABLISHED connection between 127.0.0.1:300002 to 127.0.0.1:7072

I hope I could answer ur question?

@v-braun v-braun closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants