Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Peer to Peer  (Read 2512 times)

0 Members and 1 Guest are viewing this topic.

predatorx64

  • Newbie
  • *
  • Posts: 3
    • View Profile
Peer to Peer
« on: March 30, 2011, 09:09:25 pm »
Hey Guys,
im trying to write a program to send messages from one computer to another, on my LAN it is working properly!
But when i try to use it over the internet, i can not establish a connection and im sure that i have to do something additional, but not what to do!
And im not sure what keywords i need for research...

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Peer to Peer
« Reply #1 on: March 31, 2011, 01:37:08 am »
The problem is probably that the one who listens for the connection is behind a router, therefore NAT (Network Address Translation) has to take place.

It works as follows: Say you listen on port 1234 on your computer. Now a person wants to connect to you through the internet. He goes all the way from his computer to the router, internet and stops at your router. The latter now doesn't have a clue what to do with that packet. It just recognizes it's for port 1234. But it doesn't know for who in the local network that packet is.

Therefore you have to make clear that all packets that arrive at port 1234 need to be forwarded (thus why it's called port forwarding) to your IP address in the LAN. This can be usually done through your router's configuration.

predatorx64

  • Newbie
  • *
  • Posts: 3
    • View Profile
Peer to Peer
« Reply #2 on: March 31, 2011, 01:41:10 pm »
But in this case i have to config the targetsystem everytime before i can use my program, my question was if there is a way to establish a connection without changing the routersettings?

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Peer to Peer
« Reply #3 on: March 31, 2011, 02:11:52 pm »
No, you can't. That's how it works.

There exist techniques like UPnP or STUN to get UDP connections working over NAT, but for TCP connections, you have to setup port forwarding.

Btw., many users use Hamachi for such purposes. :)

predatorx64

  • Newbie
  • *
  • Posts: 3
    • View Profile
Peer to Peer
« Reply #4 on: March 31, 2011, 07:36:03 pm »
Ok, thank you very much, i tested what you said and it works properly!

 

anything