Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How come I dont need to set port forwarding for various applications?

Options
  • 05-12-2011 11:58pm
    #1
    Registered Users Posts: 377 ✭✭


    If I write a simple c# program that runs as a server on my machine I have to forward a port from the router and open a port in windows firewall so that a client can connect to it.

    However any program I have ever downloaded from the net, I have never once had to manually forward a port from the router and open a port in windows firewall. So anyone know why that is the case?


Comments

  • Closed Accounts Posts: 2,219 ✭✭✭Lab_Mouse


    If I write a simple c# program that runs as a server on my machine I have to forward a port from the router and open a port in windows firewall so that a client can connect to it.

    However any program I have ever downloaded from the net, I have never once had to manually forward a port from the router and open a port in windows firewall. So anyone know why that is the case?

    i'd say the software does it for you..


  • Registered Users Posts: 5,376 ✭✭✭DublinDilbert


    It depends what protocols are being used and how they are used. There are tricks for punching holes in firewalls and establishing connections. Google 'nat hole punching'. This is how skype/msn ect work....


  • Registered Users Posts: 377 ✭✭irishdude11


    Lab_Mouse wrote: »
    i'd say the software does it for you..

    Well yes, obviously, but how are they doing it. It seems every other application needs to open ports so I assume there is some standard procedure for it?


  • Registered Users Posts: 5,376 ✭✭✭DublinDilbert


    Well yes, obviously, but how are they doing it. It seems every other application needs to open ports so I assume there is some standard procedure for it?

    There are ways to actually open ports using UPNP on the NAT/Router, but very few programs actually do this, as it won't work with every router / NAT out there.

    So if you want to write a skype/msn application and want to make connections between two hosts, which could both be behind NAT devices, other tricks have to be employed.

    What application are you looking to develop? or are you just trying to understand whats happening? the major trick employed is nat hole punching, that tricks the fire wall into opening up ports / forwarding on packets.


  • Registered Users Posts: 377 ✭✭irishdude11


    There are ways to actually open ports using UPNP on the NAT/Router, but very few programs actually do this, as it won't work with every router / NAT out there.

    So if you want to write a skype/msn application and want to make connections between two hosts, which could both be behind NAT devices, other tricks have to be employed.

    What application are you looking to develop? or are you just trying to understand whats happening? the major trick employed is nat hole punching, that tricks the fire wall into opening up ports / forwarding on packets.

    Cheers for that info. As for applications, Im looking to develop a peer to peer application but there won't be any sharing of files. Just need users to be able to send instant messages and small packets of data and I think it would be best practise if they connected directly to each other rather than through a server.


  • Advertisement
  • Registered Users Posts: 5,376 ✭✭✭DublinDilbert


    Cheers for that info. As for applications, Im looking to develop a peer to peer application but there won't be any sharing of files. Just need users to be able to send instant messages and small packets of data and I think it would be best practise if they connected directly to each other rather than through a server.

    IF both hosts are directly on the internet, have proper external IP addresses, are not behind NATs, yep you should be able to do the above without a 3rd party server.

    If your trying to create an instant message type setup then you'll probably need a 3 party server to help establish the connection. The 3rd party server is like a man in the middle and helps establish the connection between the 2 hosts.

    http://dcpp.wordpress.com/2010/02/13/passive-mode-c-c-connections-and-nat-traversal/

    http://dcpp.files.wordpress.com/2010/02/after_hole_punching.png?w=345&h=372

    http://en.wikipedia.org/wiki/Hole_punching


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I'd suggest that many/most apps you download are client only, which means they initiate a connection to a server somewhere else. NAT is clever enough to understand and track this and automatically direct the incoming message appropriately.

    A lot of peer to peer or server apps will either need ports forwarded, use techniques like hole punching as above, or protocols such as uPNP


  • Registered Users Posts: 1,657 ✭✭✭komodosp


    If I write a simple c# program that runs as a server on my machine I have to forward a port from the router and open a port in windows firewall so that a client can connect to it.

    However any program I have ever downloaded from the net, I have never once had to manually forward a port from the router and open a port in windows firewall. So anyone know why that is the case?

    Because your C# program is the server, and others have to connect to you. I'm willing to guess any program you've ever downloaded has been a client, so you are making an outgoing connection.


Advertisement