I have my Addresses in the Text Document formatted a specific way.Code:using System; using System.Net; using System.Net.Sockets; using System.IO; /// <summary> /// Summary description for Class1. /// </summary> class Proxy { private const string FILE_NAME = "MyFile.txt"; /// <summary> /// The main entry point for the application. /// </summary> public static void Main(String[] args) { if (!File.Exists(FILE_NAME)) { Console.WriteLine("{0} does not exist.", FILE_NAME); return; } else { StreamReader sr = File.OpenText(FILE_NAME); string input; while ((input = sr.ReadLine()) != null) { try { Socket s = ConnectSocket(server, port); } catch (Exception e) { Console.WriteLine(e.ToString()); } } Console.WriteLine ("End Of {0}", FILE_NAME); sr.Close(); } Console.ReadLine(); } private static Socket ConnectSocket(string server, int port) { Socket s = null; IPHostEntry hostEntry = null; hostEntry = Dns.Resolve(server); foreach(IPAddress address in hostEntry.AddressList) { IPEndPoint ipe = new IPEndPoint(address, port); Socket tempSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); Console.WriteLine("Establishing Connection To {0} on Port {1} ...", address, port); tempSocket.Connect(ipe); if(tempSocket.Connected == true) { Console.WriteLine("Connection Established!"); s = tempSocket; break; } else { Console.WriteLine("Connection Failed!"); continue; } } return s; } }
Example: 255.255.255.255:1080@SOCKS4
I'm trying to get all three different pieces of information and store them. I also want to make sure all pieces of information have been entered, as well as check for any formatting errors, maybe tell the user what line it was on etc..
However, i really have no idea how to do this... i was experimenting with some input.split but that just did not work out how i was hoping...
Thanks
- Joel





Reply With Quote