private void test() { NodeServer server = new NodeServer(); server.Start(); for (int i = 0; i < 100; i++) { FAP.Network.Client.Client c = new FAP.Network.Client.Client(); c.Test(); } System.Console.ReadKey(); }
public void Start(int inport) { listener = new NodeServer(); listener.OnRequest += listener_OnRequest; bool trybind = true; int port = inport; do { try { listener.Start(IPAddress.Parse(model.LocalNode.Host), port); trybind = false; if (isServer) { var f = new FAPServerHandler(IPAddress.Parse(model.LocalNode.Host), port, model, container.Resolve<MulticastClientService>(), container.Resolve<LANPeerFinderService>(), container.Resolve<MulticastServerService>()); fap = f; f.Start("Local", "Local"); } else { var f = new FAPClientHandler(model, container.Resolve<ShareInfoService>(), container.Resolve<IConversationController>(), container.Resolve<BufferService>(), container.Resolve<ServerUploadLimiterService>()); fap = f; f.Start(); model.ClientPort = port; } } catch { //Try again port++; if (inport + 100 < port) { throw new Exception("Could to bind listener"); } } } while (trybind); }