public NetworkStreamEx(SocketEx socket, bool ownsSocket)
 {
     this._asyncCtx   = new AsyncBase();
     this._access     = FileAccess.ReadWrite;
     this._socket     = socket;
     this._ownsSocket = ownsSocket;
 }
 public NetworkStreamEx(SocketEx socket, FileAccess access)
 {
     this._asyncCtx = new AsyncBase();
     this._access   = FileAccess.ReadWrite;
     this._socket   = socket;
     this._access   = access;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Ends a pending asynchronous read.
        /// </summary>
        /// <param name="asyncResult">
        /// An
        /// <see cref="System.IAsyncResult">IAsyncResult</see>
        /// that stores state information for this asynchronous operation.
        /// </param>
        /// <returns>The number of bytes read.</returns>
        ///
        /// <exception cref="System.ObjectDisposedException">
        /// The <see cref="BytesRoad.Net.Sockets.NetworkStreamEx"/> object was disposed.
        /// </exception>
        ///
        /// <exception cref="System.ArgumentNullException">
        /// <i>asyncResult</i> is a null reference
        /// (<b>Nothing</b> in Visual Basic).
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// <i>asyncResult</i> was not returned by a call to the
        /// <see cref="BytesRoad.Net.Sockets.NetworkStreamEx.BeginRead"/>
        /// method.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// <b>EndRead</b> was previously called for the
        /// asynchronous read.
        /// </exception>
        ///
        /// <exception cref="System.Net.Sockets.SocketException">
        /// An error occurred when attempting to access
        /// the socket which is used to complete the requested operation.
        /// </exception>
        ///
        /// <remarks>
        /// <b>EndRead</b> is a blocking method that completes the
        /// asynchronous read operation started in the
        /// <see cref="BytesRoad.Net.Sockets.NetworkStreamEx.BeginRead"/> method.
        ///
        /// <para>
        /// The read operation will not completed until the number of bytes specified by <i>size</i>
        /// parameter (to <b>BeginRead</b> method) is read from the stream. If the remote host shuts down the
        /// <see cref="BytesRoad.Net.Sockets.SocketEx"/>
        /// connection with the
        /// <see cref="BytesRoad.Net.Sockets.SocketEx.Shutdown"/>
        /// method, and all available data has been received, the <b>Read</b> method
        /// will complete and return number of bytes was read.
        /// </para>
        ///
        /// <note>
        /// The <b>NetworkStreamEx</b> should have access right to read data from the network stream.
        /// You may use <see cref="BytesRoad.Net.Sockets.NetworkStreamEx.CanRead"/> property to check this.
        /// </note>
        ///
        /// </remarks>
        public override int EndRead(IAsyncResult asyncResult)
        {
            AsyncBase.VerifyAsyncResult(asyncResult, typeof(Read_SO), "EndRead");
            _asyncCtx.HandleAsyncEnd(asyncResult, true);
            Read_SO stateObj = (Read_SO)asyncResult;

            return(stateObj.Read);
        }
Exemplo n.º 4
0
        internal FtpDataConnection EndExecute(IAsyncResult ar)
        {
            AsyncBase.VerifyAsyncResult(ar, typeof(GetDC_SO));
            HandleAsyncEnd(ar, true);
            GetDC_SO stateObj = (GetDC_SO)ar;

            return(stateObj.DC);
        }
Exemplo n.º 5
0
        //private int __IgCount = 1;
        #endregion

        #region 构造函数
        /// <summary>
        /// Initializes a new instance of the <see cref="eTerm443Async"/> class.
        /// </summary>
        public eTerm443Async() : base()
        {
            ValidateTSession = new AsyncBase <eTerm443Async, eTerm443Packet> .ValidateTSessionCallback(
                delegate(eTerm443Packet Packet, eTerm443Async Async) {
                byte[] OriginalBytes = Packet.OriginalBytes;
                return(!(OriginalBytes[OriginalBytes.Length - 1] == 0x00));
            });
        }
        public override int EndRead(IAsyncResult asyncResult)
        {
            AsyncBase.VerifyAsyncResult(asyncResult, typeof(Read_SO), "EndRead");
            this._asyncCtx.HandleAsyncEnd(asyncResult, true);
            Read_SO d_so = (Read_SO)asyncResult;

            return(d_so.Read);
        }
Exemplo n.º 7
0
        internal FtpItem[] EndExecute(IAsyncResult ar)
        {
            AsyncBase.VerifyAsyncResult(ar, typeof(List_SO));
            HandleAsyncEnd(ar, true);

            FtpItem[] ret = new FtpItem[_items.Count];
            _items.CopyTo(ret);
            return(ret);
        }
Exemplo n.º 8
0
 internal void EndExecute(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(Reset_SO));
     HandleAsyncEnd(ar, false);
 }
 private void EndSubNegotiation_UsernamePassword(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(UsernamePassword_SO));
     this.HandleAsyncEnd(ar, true);
 }
Exemplo n.º 10
0
 private void EndReadWhole(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(ReadWhole_SO));
     this.HandleAsyncEnd(ar, false);
 }
Exemplo n.º 11
0
 private byte[] EndReadVerifyReply(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(ReadVerifyReply_SO));
     this.HandleAsyncEnd(ar, false);
     return(((ReadVerifyReply_SO)ar).Reply);
 }
Exemplo n.º 12
0
 private void EndNegotiate(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(Negotiation_SO));
     this.HandleAsyncEnd(ar, false);
 }
Exemplo n.º 13
0
 internal override void EndBind(IAsyncResult asyncResult)
 {
     AsyncBase.VerifyAsyncResult(asyncResult, typeof(Bind_SO), "EndBind");
     this.HandleAsyncEnd(asyncResult, true);
 }
Exemplo n.º 14
0
 internal override SocketBase EndAccept(IAsyncResult asyncResult)
 {
     AsyncBase.VerifyAsyncResult(asyncResult, typeof(Accept_SO), "EndAccept");
     this.HandleAsyncEnd(asyncResult, true);
     return(this);
 }
Exemplo n.º 15
0
 internal void EndExecute(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(PutFile_SO));
     HandleAsyncEnd(ar, true);
 }
Exemplo n.º 16
0
 internal override int EndReceive(IAsyncResult asyncResult)
 {
     AsyncBase.VerifyAsyncResult(asyncResult, typeof(Receive_SO), "EndReceive");
     this.HandleAsyncEnd(asyncResult, false);
     return(((Receive_SO)asyncResult).Read);
 }
 public override void EndWrite(IAsyncResult asyncResult)
 {
     AsyncBase.VerifyAsyncResult(asyncResult, typeof(Write_SO), "EndWrite");
     this._asyncCtx.HandleAsyncEnd(asyncResult, true);
 }
Exemplo n.º 18
0
 internal override void EndConnect(IAsyncResult asyncResult)
 {
     AsyncBase.VerifyAsyncResult(asyncResult, typeof(Connect_SO), "EndConnect");
     this.HandleAsyncEnd(asyncResult, true);
 }
Exemplo n.º 19
0
 private void EndDoAuthentication(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(DoAuthentication_SO));
     this.HandleAsyncEnd(ar, false);
 }
Exemplo n.º 20
0
 internal string EndExecute(IAsyncResult ar)
 {
     AsyncBase.VerifyAsyncResult(ar, typeof(PutFileUnique_SO));
     HandleAsyncEnd(ar, true);
     return(_uniqueFileName);
 }