Esempio n. 1
0
        static void Connect(string input)
        {
            try
            {
                string pInput = input.Split()[1];

                int IPStart   = 0;
                int IPEnd     = pInput.IndexOf(':');
                int PortStart = pInput.IndexOf(':') + 1;
                int PortEnd   = pInput.Length - PortStart;

                string IP   = pInput.Substring(IPStart, IPEnd);
                string Port = pInput.Substring(PortStart, PortEnd);

                try
                {
                    ClientHandler.Connect(IP, Int32.Parse(Port));
                    if (ClientHandler.client != null)
                    {
                        Console.WriteLine("Connected to " + IP + ":" + Port + "!\n");
                    }
                    if (ClientHandler.client == null)
                    {
                        Console.WriteLine("Connection to " + IP + ":" + Port + "has failed!\n");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("The correct syntax is 'conn (ip):(port)'.\n");
                    ClientHandler.client = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error has occurred: " + ex.Message + "\n");
            }
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     client.Connect("localhost", 55555);
 }