Пример #1
0
        static void Main(string[] args)
        {
            LahoreSocketClient client       = new LahoreSocketClient();
            string             strIPAddress = MyServer.ipAddr;
            string             strPortInput = MyServer.mPort.ToString();

            if (!client.SetServerIPAddress(strIPAddress))
            {
                Console.WriteLine(strIPAddress, "is the wrong IP Address");
            }
            else if (!client.SetPortNumber(strPortInput))
            {
                Console.WriteLine(strPortInput, "is the wrong port number");
            }
            else
            {
                client.ConnectToServer();
                string strInputUser = null;
                do
                {
                    strInputUser = Console.ReadLine();
                    if (!(strInputUser.Trim().Equals("<EXIT>")))
                    {
                        client.SendToServer(strInputUser);
                    }
                    else
                    {
                        client.CloseAndDisconnect();
                    }
                }while (!(strInputUser.Trim().Equals("<EXIT>")));
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            LahoreSocketClient client = new LahoreSocketClient();

            client.RaiseTextReceivedEvent  += HandleTextReceived;
            client.RaiseServerDisconnected += HandleServerDisconnected;
            client.RaiseServerConnected    += HandleServerConnected;

            Console.WriteLine("*** Welcome to Socket Client Starter Example by Naeem Akram Malik ***");
            Console.WriteLine("Please Type a Valid Server IP Address or hostname formatted as <HOST> and Press Enter: ");

            string strIPAddress = Console.ReadLine();

            Console.WriteLine("Please Supply a Valid Port Number 0 - 65535 and Press Enter: ");
            string strPortInput = Console.ReadLine();

            if (strIPAddress.StartsWith("<HOST>"))
            {
                strIPAddress = strIPAddress.Replace("<HOST>", string.Empty);
                strIPAddress = Convert.ToString(LahoreSocketClient.ResolveHostNameToIPAddress(strIPAddress));
            }

            if (string.IsNullOrEmpty(strIPAddress))
            {
                Console.WriteLine("No IP Address Supplied...");
                Environment.Exit(0);
            }

            if (!client.SetServerIPAddress(strIPAddress) ||
                !client.SetPortNumber(strPortInput))
            {
                Console.WriteLine(
                    string.Format(
                        "Wrong IP Address or port number supplied - {0} - {1} - Press a key to exit",
                        strIPAddress,
                        strPortInput));
                Console.ReadKey();
                return;
            }

            client.ConnectToServer();

            string strInputUser = null;

            do
            {
                strInputUser = Console.ReadLine();

                if (strInputUser.Trim() != "<EXIT>")
                {
                    client.SendToServer(strInputUser);
                }
                else if (strInputUser.Equals("<EXIT>"))
                {
                    client.CloseAndDisconnect();
                }
            } while (strInputUser != "<EXIT>");
        }
Пример #3
0
        static void Main(string[] args)
        {
            LahoreSocketClient client = new LahoreSocketClient();

            client.RaiseTextReceivedEvent  += HandleTextReceived;
            client.RaiseServerDisconnected += HandleServerDisconnected;
            client.RaiseServerConnected    += HandleServerConnected;

            Console.WriteLine("*** Welcome to Socket Client Starter Example by Naeem Akram Malik ***");
            Console.WriteLine("Please Type a Valid Server IP Address and Press Enter: ");

            string strIPAddress = "89.229.95.152";

            Console.WriteLine("Please Supply a Valid Port Number 0 - 65535 and Press Enter: ");
            string strPortInput = "16010";

            if (!client.SetServerIPAddress(strIPAddress) ||
                !client.SetPortNumber(strPortInput))
            {
                Console.WriteLine(
                    string.Format(
                        "Wrong IP Address or port number supplied - {0} - {1} - Press a key to exit",
                        strIPAddress,
                        strPortInput));
                Console.ReadKey();
                return;
            }

            client.ConnectToServer();

            string strInputUser = null;

            do
            {
                strInputUser = Console.ReadLine();

                if (strInputUser.Trim() != "<EXIT>")
                {
                    client.SendToServer(strInputUser);
                }
                else if (strInputUser.Equals("<EXIT>"))
                {
                    client.CloseAndDisconnect();
                }
            } while (strInputUser != "<EXIT>");
        }
Пример #4
0
        static void Main(string[] args)
        {
            LahoreSocketClient client = new LahoreSocketClient();

            client.RaiseTextreceivedEvent += HandleTextReceived;

            Console.WriteLine("Welcome to socket Client Starter Eample :D");
            Console.WriteLine("Please type a valid server IP Address and press enter");

            string strIPAddress = "89.228.240.20";//Console.ReadLine();



            Console.WriteLine("Please Supply a Valid port Number 0 - 65335 and press Enter: ");
            string strPortInput = "16010";//Console.ReadLine();


            if (!client.SetServerIPAdress(strIPAddress) || !client.SetPortNumber(strPortInput))
            {
                Console.WriteLine("Wront IP Address or port nymber suppliet - {0} - {1} - Press a ke y to exit", strIPAddress, strPortInput);
                Console.ReadKey();
                return;
            }

            client.ConnectToServer();


            string strInputUser = null;

            do
            {
                strInputUser = Console.ReadLine();
                if (strInputUser.Trim() != "<EXIT>")
                {
                    client.SendToServer(strInputUser);
                }
                else if (strInputUser.Equals("<EXIT>"))
                {
                    client.CloseAndDisconnect();
                }
            } while (strInputUser != "<EXIT>");
        }
Пример #5
0
 private void DisconnectBtn(object sender, EventArgs e)
 {
     client.CloseAndDisconnect();
 }