Author Topic: Local server  (Read 15450 times)

Tauti

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Local server
« on: September 19, 2014, 07:08:19 AM »
Hi.
I can not start the server when disconnected internet, get the error window: , when connected to the internet it works: . How to run LAN server ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Local server
« Reply #1 on: September 19, 2014, 10:05:58 PM »
You don't need the internet. You just need LAN.

Problem is in your case you don't even seem to have LAN. 127.0.0.1 is your loopback address. If you had LAN, you'd see your LAN IP instead.

You disconnected the network cable. There is no LAN.

Tauti

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Local server
« Reply #2 on: September 20, 2014, 02:58:01 PM »
Thanks for the answer, you did not understand me, when I disconnected the network cable the server not start, getting error http://savepic.net/6127974.htm

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Local server
« Reply #3 on: September 21, 2014, 09:28:26 AM »
I understood you fine. When there is no network connection at all, you don't actually have any network addresses to work with. What's the point of running a network server if there is no network?

Tauti

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Local server
« Reply #4 on: September 21, 2014, 01:37:32 PM »
To test the application on the same computer.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Local server
« Reply #5 on: September 22, 2014, 10:44:53 AM »
And why do you need to disconnect the network cable for that?

Tauti

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Local server
« Reply #6 on: September 22, 2014, 09:45:23 PM »
I do not disconnect the cable when disconnected internet (usb mobile modem) server is not running. For example older versions 1.8.x runs perfectly, 1.9.x not work

MCoburn

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 7
  • Posts: 69
    • View Profile
Re: Local server
« Reply #7 on: September 23, 2014, 12:14:20 AM »
I think what he means that he's connected to the outside world by his 3G internet modem and he doesn't have LAN network.

If you use the public IP of the 3G Modem, let's say 50.x.x.x, TNet should automatically realize that is your computer connecting to itself, and it would be like a loopback - no actual packets going to some random host on the internet then back to your connection.

Some ADSL modem routers do the same thing, you punch in your external IP and they treat it like a internal network connection.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Local server
« Reply #8 on: September 23, 2014, 01:03:04 PM »
@MCoburn: No, you can clearly see that in one screenshot the LAN network is connected, and in the other it's disconnected. 3G would show a wifi symbol, not a LAN icon.

@Tauti: You can try changing TNTools.localAddress to this:
  1.         static public IPAddress localAddress
  2.         {
  3.                 get
  4.                 {
  5.                         if (mLocalAddress == null)
  6.                         {
  7.                                 mLocalAddress = IPAddress.Loopback;
  8.                                 List<IPAddress> list = localAddresses;
  9.  
  10.                                 if (list.size > 0)
  11.                                 {
  12.                                         mLocalAddress = mAddresses[0];
  13.  
  14.                                         for (int i = 0; i < mAddresses.size; ++i)
  15.                                         {
  16.                                                 IPAddress addr = mAddresses[i];
  17.                                                 string str = addr.ToString();
  18.  
  19.                                                 // Hamachi IPs begin with 25
  20.                                                 if (str.StartsWith("25.")) continue;
  21.  
  22.                                                 // This is a valid address
  23.                                                 mLocalAddress = addr;
  24.                                                 break;
  25.                                         }
  26.                                 }
  27.                         }
  28.                         return mLocalAddress;
  29.                 }
  30.                 set
  31.                 {
  32.                         mLocalAddress = value;
  33.  
  34.                         if (value != null)
  35.                         {
  36.                                 List<IPAddress> list = localAddresses;
  37.                                 for (int i = 0; i < list.size; ++i)
  38.                                         if (list[i] == value)
  39.                                                 return;
  40.                         }
  41. #if UNITY_EDITOR
  42.                         UnityEngine.Debug.LogWarning("[TNet] " + value + " is not one of the local IP addresses. Strange things may happen.");
  43. #else
  44.                         System.Console.WriteLine("[TNet] " + value + " is not one of the local IP addresses. Strange things may happen.");
  45. #endif
  46.                 }
  47.         }
...however I'd need to know the version of TNet you're using, and the line on where the issue occurs. For that to happen you should run the application via Unity, or from Visual Studio, not by running the server executable.

P.S. You can also add an early exit after line 120 in the same file:
  1. UnicastIPAddressInformationCollection uniAddresses = props.UnicastAddresses;
  2. if (uniAddresses == null) continue; // <-- this
...but again, I need to know the line number where the crash happens.

Tauti

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Local server
« Reply #9 on: September 23, 2014, 09:06:11 PM »
@MCoburn as says Aren, see screenshots.
@ArenMook Version 1.9.7,  perhaps this is a problem windows, running the server on a laptop no error, :o hmm....

Tauti

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Local server
« Reply #10 on: September 23, 2014, 09:33:46 PM »
Looks like an error occurs when trying to determine the external ip in my computer

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Local server
« Reply #11 on: September 24, 2014, 02:54:04 PM »
Tools.externalAddress calls GetExternalAddress(), which calls ResolveExternalIP() several times until it's able to determine the external address. ResolveExternalIP()'s contents are wrapped in a try/catch block, so nothing that goes wrong inside will cause it to crash. Not sure about your version, but that's how it's like in 1.9.9.