Exemplo n.º 1
0
        public virtual void Start(string remote, int remoteport)
        {
            try
            {
                ConnectRemote(remote, remoteport);

                Host.OnConnect(this);

                SourceStream.BeginRead(SourceBuffer, 0, BufferSize, BeginReceive, SourceStream);
                RemoteStream.BeginRead(RemoteBuffer, 0, BufferSize, BeginReceive, RemoteStream);
            }
            catch (Exception ex)
            {
                Host.OnException(this, ex);
            }
        }
Exemplo n.º 2
0
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            void wrappedCallback(IAsyncResult result)
            {
                lastRead = SourceStream.EndRead(result);
                outStream.Write(buffer, offset, lastRead);
                callback?.Invoke(result);
            }

            return(SourceStream.BeginRead(buffer, offset, count, wrappedCallback, state));
        }