Inheritance: BufferStream
コード例 #1
0
        public async Task MainTest()
        {
            var client = new TcpClient();
            await client.ConnectAsync("192.168.1.201", 23);

            var networkStream = client.GetStream();

            using (var stream = new TelnetStream(networkStream.ReadAsync, networkStream.WriteAsync, () => networkStream.DataAvailable))
                using (var reader = new StreamReader(stream, Encoding.ASCII))
                    using (var writer = new StreamWriter(stream, Encoding.ASCII))
                    {
                        if (await WaitForPrompt(reader, "login:"******"root");

                            await writer.FlushAsync();

                            if (await WaitForPrompt(reader, "Password:"******"hong");

                                await writer.FlushAsync();
                                await WaitForPrompt(reader, "$");
                            }
                        }
                    }
        }
コード例 #2
0
        public async Task MainTest()
        {
            var client = new TcpClient();
            await client.ConnectAsync("192.168.1.201", 23);
            var networkStream = client.GetStream();

            using (var stream = new TelnetStream(networkStream.ReadAsync, networkStream.WriteAsync, () => networkStream.DataAvailable))
            using (var reader = new StreamReader(stream, Encoding.ASCII))
            using (var writer = new StreamWriter(stream, Encoding.ASCII))
            {
                if (await WaitForPrompt(reader, "login:"******"root");
                    await writer.FlushAsync();

                    if (await WaitForPrompt(reader, "Password:"******"hong");
                        await writer.FlushAsync();
                        await WaitForPrompt(reader, "$");
                    }
                }
            }
        }