Author Topic: TNServer and TNManager.Start()  (Read 1980 times)

blueagardq15

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
TNServer and TNManager.Start()
« on: July 27, 2015, 11:14:49 PM »
Hi, I can connect to the TNServer when it is running, but I cannot connect to to a server when I Create a server Like in this code: The code below was used from a coding from a different post on this forum.

  1. int udpPort = Random.Range(10000, 40000);
  2.                         TNLobbyClient lobby = TN.GetComponent<TNLobbyClient>();
  3.                        
  4.                         if (lobby == null)
  5.                         {
  6.                                 //TNServerInstance.Start(tcpPort,udpPort,lobbyPort,"server.dat");
  7.                                 TNServerInstance.Start(5129, udpPort, "server.dat");  
  8.                         }
  9.                         else
  10.                         {
  11.                                 //Hosting Server
  12.                                 //mMessage = "Server started";
  13.                                 TNServerInstance.Type type = (lobby is TNUdpLobbyClient) ? TNServerInstance.Type.Udp : TNServerInstance.Type.Tcp;
  14.                                 TNServerInstance.Start(5129, udpPort, lobby.remotePort, "server.dat", type);
  15.                                
  16.                         }

If I use a TNServer, will other computers be able to connect to my server? Also would I have to run this everytime I need to create a server?

Thank you for your help.
« Last Edit: July 27, 2015, 11:38:10 PM by blueagardq15 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServer and TNManager.Start()
« Reply #1 on: July 28, 2015, 06:04:36 PM »
By default port 5129 is used for the lobby server. TNet uses port 5127 for the game server. Furthermore why are you specifying a lobby port there? You should simplify your server instantiation. Keep it trivial:
  1. TNServerInstance.Start(5127, 0, "server.dat");
What's your actual connect code? It should be:
  1. TNManager.Connect("127.0.0.1:5127");
Replace 127.0.0.1 with the actual external IP address of where this server is hosted, or it will only work when executed locally on the same PC where the server is started.