Example #1
0
        private void StartServer()
        {
            BindSocketAndListen();
            while (true)
            {
                Console.WriteLine(Clients.Count);
                Socket clientSocket = ServerSocket.Accept();
                Client cl = new Client();
                cl.KeepProcessing = true;
                cl.Socket = clientSocket;
                Clients.Add(cl); //add to clients collection
                ParameterizedThreadStart pts = new ParameterizedThreadStart(ProcessClientThreadProc);
                Thread thr = new Thread(pts);
                thr.IsBackground = true;
                thr.Start(cl); //start client processing thread
                clientSocket = null;
                cl = null;

            }
        }
Example #2
0
        static void controlCommands(string command)
        {
            if (command.StartsWith("connect"))
            {
                command = command.Replace("connect ", "");
                c = new Client(command);
            }
            else if (command.StartsWith("name"))
            {
                command = command.Replace("name ", "");
                name = command;

            }
            else if (command == "host")
            {
                ThreadStart Ref = new ThreadStart(hostSetup);
                Thread hread = new Thread(Ref);
                hread.Start();
            }
            else if (command == "again")
            {
                Process.Start("ArduinoComms.exe");
            }
            else if (command == "scan")
            {
                scan();
            }
            else
            {
                WriteLine("Command Not Understood Capitan");
            }
        }