Author Topic: 1.5.0 and UPnP  (Read 1212 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,152
  • Toronto, Canada
    • View Profile
1.5.0 and UPnP
« on: February 18, 2013, 06:33:31 AM »
You know how annoying it is to have to educate your friends on how to open up ports on their router just so that you two can play some multi-player game? Well, with TNet version 1.5.0 you don't have to! TNet will do that for you. Usage is simple -- the server examples that come with TNet (both stand-alone, and in-game) have been updated to take advantage of UPnP (stands for Universal Plug & Play btw). If you need to open up a port yourself, you can do that like so:
  1. UPnP up = new UPnP();
  2. up.OpenTCP(5127); // for a TCP port
  3. up.OpenUDP(5128); // for a UDP port
...where you replace 5127 and/or 5128 with the port you actually want to open. Keep in mind that the instance of UPnP must be present for the port to remain open, as it will be closed automatically when the instance of it is destroyed. You can also close it yourself just by calling the UPnP's Close() function.