private static ContentServerClient.StorageSession GetSteam2StorageSession(IPEndPoint [] contentServers, ContentServerClient csClient, int depotId, int depotVersion) { ContentServerClient.StorageSession session = null; if (csClient.IsConnected && contentServers.Contains(lastSteam2ContentServer)) { try { session = csClient.OpenStorage( (uint)depotId, (uint)depotVersion, (uint)Config.CellID, null, false ); return session; } catch ( Steam2Exception ) { csClient.Disconnect(); } } int tries = 0; int counterSocket = 0, counterSteam2 = 0; for (int i = 0; ; i++) { IPEndPoint endpoint = contentServers[i % contentServers.Length]; try { csClient.Connect( endpoint ); session = csClient.OpenStorage( (uint)depotId, (uint)depotVersion, (uint)Config.CellID, GetSteam2Credentials( (uint)depotId ), true ); lastSteam2ContentServer = endpoint; break; } catch ( SocketException ) { counterSocket++; } catch ( Steam2Exception ) { csClient.Disconnect(); counterSteam2++; } if (((i + 1) % contentServers.Length) == 0) { if (++tries > MAX_CONNECT_RETRIES) { Console.WriteLine("\nGiving up finding Steam2 content server."); return null; } Console.WriteLine("\nSearching for content servers... (socket error: {0}, steam2 error: {1})", counterSocket, counterSteam2); counterSocket = 0; counterSteam2 = 0; Thread.Sleep(1000); } } return session; }