public static DistCacheClient Create(DistCacheClientConfig config) { TcpClient tcp = null; IPEndPoint toTry; Dictionary <IPEndPoint, bool> invalidEndPoints = new Dictionary <IPEndPoint, bool>(); while ((toTry = config.GetOrderedServerIpEndPoint().FirstOrDefault(i => !invalidEndPoints.ContainsKey(i))) != null) { try { tcp = SocketHandler.CreateSocket(toTry, config); } catch (Exception ex) { tcp = null; invalidEndPoints[toTry] = true; } if (tcp != null) { break; } } if (tcp != null) { return(new DistCacheClient(tcp, config)); } throw new Exception("could not connect to any node"); }