Exemple #1
0
        public static void Main(string[] args)
        {
            bool notdone = true;             // variable used to check if the client needs to exit or not

            //Create a client
            Client client = new Client();


            //Loop until command 'quit' is entered
            while (notdone)
            {
                try
                {
                    // Establish connection to Server
                    client.Connect();

                    // Get message to be sent to server
                    String clientMsge = client.GetClientMsge();

                    // Check if the client wants to disconnect message to be sent to server
                    notdone = client.CheckToTerminate(clientMsge);

                    // Send data to Server
                    client.TransmitMsgeToServer(clientMsge);

                    // Receive and print message from Server
                    client.ReceiveMsgeFromServer();

                    // Close Tcp connection
                    client.Disconnect();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error... " + e.StackTrace);
                }
            }
        }