コード例 #1
0
        /// <summary>
        ///   Requests the home page via WebClient.
        /// </summary>
        public static void PrimeServerHomepage()
        {
            LoggerClient.Log("Priming Server Homepage...");
            using (var wc = new WebClient()) {
                try {
                    wc.DownloadString(DeleporterConfiguration.SiteBaseUrl);
                } catch (WebException webException) {
                    var responseStream = webException.Response.GetResponseStream();
                    var streamReader   = new StreamReader(responseStream);

                    LoggerClient.Log("Failed to prime the server. {0}", webException.Message);

                    var message = string.Format("Failed to prime the server. {0} {1}", webException.Message, streamReader.ReadToEnd());
                    throw new Exception(message);
                }
            }
            LoggerClient.Log("Finished Priming Server Homepage");
        }
コード例 #2
0
        public static int FindNextAvailablePort(int startingPort)
        {
            var portToTry = startingPort;
            var available = false;

            while (!available)
            {
                available = LocalPortIsAvailable(portToTry);

                if (available)
                {
                    continue;
                }

                LoggerClient.Log("Port {0} was unavailable.  Trying {1}", portToTry, portToTry + 1);
                portToTry++;
            }

            return(portToTry);
        }