Ejemplo n.º 1
0
        public async Task Connect(string hostname, int port, TransferProtocols protocol, Encoding encoding)
        {
            Protocol = new TransferProtocolFactory().CreateTransferProtocol(protocol, encoding, new Action <string>(Log));
            Protocol.AddEventCallbacks(OnDataAvailable, OnBytesAvailable);
            Client = new TcpClient();
            Task          t = Client.ConnectAsync(hostname, port);
            await         t;
            NetworkStream stream = Client.GetStream();

            buffer = new byte[Client.ReceiveBufferSize];
            stream.BeginRead(buffer, 0, buffer.Length, ReadCallback, Client);
        }