public void Send(TNServerScreen s)
        {
            //Console.WriteLine("send screen");
            var data = s.AsTN3270Buffer(true, true, TN3270E);

            //Console.WriteLine("data.length="+data.Length);
            mSocket.Send(data);
        }
        public string WaitForKey(TNServerScreen currentScreen)
        {
            //Console.WriteLine("--wait for key");
            byte[] data   = null;
            var    screen = false;

            do
            {
                do
                {
                    while (!mDataSemaphore.Acquire(1000))
                    {
                        if (mSocket == null)
                        {
                            throw new TN3270ServerException("Connection dropped");
                        }
                    }
                    data = (byte[])mData.Dequeue();
                } while (data == null);
                if (data[0] == 255 && data[1] == 253)
                {
                    // assume do/will string
                    for (var i = 0; i < data.Length; i++)
                    {
                        if (data[i] == 253)
                        {
                            data[i] = 251; // swap DO to WILL
                            Console.WriteLine("DO " + data[i + 1]);
                        }
                        else if (data[i] == 251)
                        {
                            data[i] = 253; // swap WILL to DO
                            Console.WriteLine("WILL " + data[i + 1]);
                        }
                    }
                    mSocket.Send(data);
                    screen = false;
                }
                else
                {
                    screen = true;
                }
            } while (!screen);
            return(currentScreen.HandleTN3270Data(data, data.Length));
        }