public static bool pingPort(string strServer) { string tempPort = ""; string pingip = ""; if (strServer.Contains("http")) { strServer = strServer.Substring(strServer.IndexOfAny(new char[] { '/', '/' }) + 2); } if (strServer.Contains(":") && strServer.Contains("/")) { int startIndex = strServer.IndexOf(":"); int endIndex = strServer.IndexOf("/"); tempPort = strServer.Substring(startIndex + 1, endIndex - startIndex - 1); pingip = strServer.Substring(0, startIndex); } else if (strServer.Contains(":") && !strServer.Contains("/")) { int startIndex = strServer.IndexOf(":"); tempPort = strServer.Substring(startIndex + 1); pingip = strServer.Substring(0, startIndex); } else { tempPort = "80"; pingip = strServer; } return(ICUtility.PingPort(pingip, int.Parse(tempPort))); }
public static async Task <string> GetResponse(string strSubAddress, Dictionary <string, string> pairs, Request_type type = Request_type.TYPE_GET) { if (!ICUtility.Ping(strServer)) { return(""); } string url = "http://" + strServer + "/" + strSubAddress; return(await HttpServer.GetHttpResponse(url, pairs, 4000, type)); }