Exemple #1
0
        static void Main(string[] args)
        {
            Console.Title = "Remote";
            Client client = new Client();

            Console.WriteLine("Введите IP-адрес:");
            string ip = Console.ReadLine();
            IPAddress tryIp;
            while (!IPAddress.TryParse(ip, out tryIp))
            {
                Console.WriteLine("Введите IP-адрес:");
                ip = Console.ReadLine();
            }

            Console.WriteLine("Введите логин:");
            string login = Console.ReadLine();
            while (login.Length == 0)
            {
                Console.WriteLine("Введите логин:");
                login = Console.ReadLine();
            }
            Console.WriteLine("Введите пароль:");
            string password = Console.ReadLine();

            client.Connect(ip, 7000, login, password);

            while (!client.successful)
                Thread.Sleep(250);
            while (!client.authenticated)
                Thread.Sleep(250);

            Console.WriteLine("Введите команду:");
            client.Send(Console.ReadLine());
            while (true);
        }
Exemple #2
0
        private void start_server()
        {
            if (serverListenPort != 0)
            {
                TcpListener listener = new TcpListener(ipAddress, serverListenPort);
                try
                {
                    // Verbindungsannahme aktivieren
                    listener.Start();

                    update_log("Server auf Port " + serverListenPort.ToString() + " gestartet", 3);

                    // Warten auf Verbindung
                    update_log("Warte auf neue Verbindung.", 3);
                    while (!listener.Pending()) { Thread.Sleep(sleepTime); }
                    // Verbindung annehmen
                    Socket newSocket = listener.AcceptSocket();
                    // Mitteilung bzgl. neuer Clientverbindung
                    update_log("Neue Client-Verbindung (" +
                                "IP: " + newSocket.RemoteEndPoint + ", " +
                                "Port " + ((IPEndPoint)newSocket.LocalEndPoint).Port.ToString() + ")",3);
                    Client client_connection = new Client(newSocket);
                    ClientList.Add(client_connection);
                }
                catch(Exception exp)
                {
                    update_log(exp.Message, 1);
                }
            }
            else
            {
                update_log("Die Portnummer darf nicht 0 sein.",0);
            }
        }
Exemple #3
0
 /// <summary>
 /// Inits client.
 /// If sConn setting is true -> serial client
 /// Else -> TCPClient
 /// Connects ConnectionStatusChangedHandler
 /// </summary>
 private void initClient()
 {
     if (Convert.ToBoolean((string)Settings.get("sConn")))
     {
         c = new SerialClient((string)Settings.get("sPort"));
     }
     else
     {
         c = new TCPClient((string)Settings.get("ip"), Convert.ToInt32((string)Settings.get("port")), (string)Settings.get("password"));
     }
     c.csc += new ConnectionStatusChangedHandler(connectionStatusChanged);
 }