Ejemplo n.º 1
0
 public override void Start()
 {
     TcpClient client = new TcpClient();
     client.Connect(iporhost, port);
     connection = new DeveConnectionStreamSocket(client, this);
     connection.Start();
 }
Ejemplo n.º 2
0
        private void Runner()
        {
            tcpListener.Start();

                while (!shouldShutdown)
                {
                    if (!tcpListener.Pending())
                    {
                        Thread.Sleep(100);
                    }
                    else
                    {
                        //blocks until a client has connected to the server
                        TcpClient client = tcpListener.AcceptTcpClient();
                        Console.WriteLine("Client connected");

                        DeveConnectionStreamSocket deveClientConnection = new DeveConnectionStreamSocket(client, this);
                        deveClientConnection.Start();

                        lock (clientConnections)
                        {
                            clientConnections.Add(deveClientConnection);
                        }

                        //Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));
                        //clientThread.Start(client);
                    }
                }

                foreach (DeveConnectionStreamSocket deveClientConnection in clientConnections)
                {
                    deveClientConnection.Stop();
                }

                tcpListener.Stop();
        }