Problems with work in local network

158 views
Skip to first unread message

Artem Klushin

unread,
Aug 30, 2017, 2:00:29 PM8/30/17
to lidgren-network-gen3
Hello, I use this library for interaction between two progarams on one machine. Library doesn't work if i don't have an internet connection on a computer.

I get exception in NetPeer.Internal.cs line 179
byte[] combined = new byte[epBytes.Length + macBytes.Length];

macBytes is null, because library can't get mac address bytes.

Library try to get NetworkInterface in PlatformWin32.cs line 26 and Windows return Loopback interface. So, GetNetworkInterface() return null and I will get exception.
Can I use this library for local network messaging without internet connection?

It is some my code for initialization:

// declare variables in class
private NetServer _server;
private NetPeerConfiguration _serverConfig;

public LocalNetworkServer()
{
            // needed for RegisterReceivedCallback, TODO replace with AsyncOperationM...
            if (SynchronizationContext.Current == null)
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            _serverConfig = new NetPeerConfiguration("AdrenalineGame");
            _serverConfig.Port = 45045;
            _serverConfig.MaximumConnections = 10;
            _serverConfig.ConnectionTimeout = 10;
            _serverConfig.PingInterval = 3;
        }

public void Start()
{
            _server = new NetServer(_serverConfig);
            _server.RegisterReceivedCallback(new System.Threading.SendOrPostCallback(ReceiveDataCallback));
            _server.Start();
}
Reply all
Reply to author
Forward
0 new messages