public void Startup() { ServerServices.AddMessage(0, "Unlimited nodes."); CheckTimeoutThread = new Thread(CheckTimeout); CheckTimeoutThread.IsBackground = true; CheckTimeoutThread.Start(); ServerServices.AddMessage(0, "Starting up..."); ServerServices.AddMessage(0, "Finding LW supported file formats..."); LoadFileFormats(); ServerServices.AddMessage(0, "Setting up the server..."); SetupService(); AutoSetupServer = new BroadcastListener(Port); ServerServices.AddMessage(0, "Autodiscovery server running at UDP port 61111"); if (OfferWeb) { WebServer = new WebServer(this, OfferWebPort); } foreach (MapDrive mapDrive in _mappedDrives) { mapDrive.Mount(); } }
private void SetupService() { if (AutoOfferPort) { for (Port = 2080; Port < 60000; Port++) { try { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = Port; Channel = new TcpChannel(props, clientProv, serverProv); break; } catch (Exception ex) { logger.Error(ex, "Error finding free port"); } } } else { try { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = Port; Channel = new TcpChannel(props, clientProv, serverProv); } catch (Exception ex) { logger.Error(ex, "Error opening TCP channel"); ServerServices.AddMessage(1, "Cannot use port " + Port); return; } } ChannelServices.RegisterChannel(Channel, false); // Register ServerServices if (!RemotingConfiguration.IsActivationAllowed(typeof(ServerServices))) { RemotingConfiguration.RegisterActivatedServiceType(typeof(ServerServices)); } // Register MasterServer if (!RemotingConfiguration.IsActivationAllowed(typeof(MasterServer))) { RemotingConfiguration.RegisterActivatedServiceType(typeof(MasterServer)); } ServerServices.AddMessage(0, "Server running at port " + Port); }
public WebServer(MasterServer server, int port) { _server = server; try { _listener = new TcpListener(IPAddress.Any, port); _listener.Start(10); _needToStop = false; _threadListener = new Thread(StartAccepting); _threadListener.IsBackground = true; _threadListener.Start(); } catch (Exception ex) { Debug.WriteLine("Cannot start web server: " + ex); ServerServices.AddMessage(1, "Cannot start web server on port " + port); return; } ServerServices.AddMessage(0, "Web server ready to accept connections on port " + port); }
public void AddMessage(int icon, string msg) { ServerServices.AddMessage(icon, msg); }