コード例 #1
0
 /// <summary>
 /// Accepts a pending connection request.
 /// </summary>
 /// <returns>A <see cref="SecureSocket"/> used to send and receive data.</returns>
 /// <exception cref="InvalidOperationException">The listener has not been started with a call to Start.</exception>
 /// <exception cref="SocketException">An operating system error occurs while accessing the SecureSocket.</exception>
 /// <exception cref="SecurityException">Unable to create the SSPI credentials.</exception>
 /// <remarks>AcceptSocket returns a SecureSocket that you can use to send and receive data. This SecureSocket is initialized with the IP address and port number of the remote machine. You can use any of the Send and Receive methods available in the Socket class to communicate with the remote machine.<br><b>Note</b>   When you finish using the Socket, be sure to call its Close method.</br><br><b>Note</b>   If your application is relatively simple, consider using the AcceptTcpClient method rather than AcceptSocket. SecureTcpClient provides you with simple methods for sending and receiving data over a network.</br></remarks>
 public virtual SecureSocket AcceptSocket(ISocketMonitor monitor = null)
 {
     if (Server == null)
     {
         throw new InvalidOperationException();
     }
     return((SecureSocket)Server.Accept(monitor));
 }
コード例 #2
0
        /// <summary>
        /// Ends an asynchronous request to create a new <see cref="SecureSocket"/> to accept an incoming connection request.
        /// </summary>
        /// <param name="asyncResult">Stores state information for this asynchronous operation as well as any user defined data.</param>
        /// <returns>A SecureSocket to handle the incoming connection.</returns>
        /// <remarks>The returned <see cref="VirtualSocket"/> can be cast to a SecureSocket if necessary.</remarks>
        /// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="asyncResult"/> was not created by a call to <see cref="BeginAccept"/>.</exception>
        /// <exception cref="SocketException">An operating system error occurs while accessing the SecureSocket.</exception>
        /// <exception cref="ObjectDisposedException">The SecureSocket has been closed.</exception>
        /// <exception cref="SecurityException">Unable to create the credentials -or- client authentication error.</exception>
        public override VirtualSocket EndAccept(IAsyncResult asyncResult, CancellationToken cancel, ISocketMonitor monitor = null)
        {
            // Make sure everything is in order
            if (asyncResult == null)
                throw new ArgumentNullException();
            if (m_AcceptResult == null)
                throw new InvalidOperationException();
            if (m_AcceptResult != asyncResult)
                throw new ArgumentException();
            AsyncAcceptResult ar = m_AcceptResult;
            // Process the (secure) EndAccept
            // block if the operation hasn't ended yet
            while (!ar.IsCompleted)
            {
                ar.AsyncWaitHandle.WaitOne(200, false);
            }

            if (cancel.IsCancellationRequested)
            {
                cancel.ThrowIfCancellationRequested();
                return null;
            }

            m_AcceptResult = null;
            if (ar.AsyncException != null)
                throw ar.AsyncException;

            if (monitor != null)
                monitor.Attach(ar.AcceptedSocket);

            return ar.AcceptedSocket;
        }
コード例 #3
0
 /// <summary>
 /// Accepts a pending connection request.
 /// </summary>
 /// <returns>A <see cref="SecureSocket"/> used to send and receive data.</returns>
 /// <exception cref="InvalidOperationException">The listener has not been started with a call to Start.</exception>
 /// <exception cref="SocketException">An operating system error occurs while accessing the SecureSocket.</exception>
 /// <exception cref="SecurityException">Unable to create the SSPI credentials.</exception>
 /// <remarks>AcceptSocket returns a SecureSocket that you can use to send and receive data. This SecureSocket is initialized with the IP address and port number of the remote machine. You can use any of the Send and Receive methods available in the Socket class to communicate with the remote machine.<br><b>Note</b>   When you finish using the Socket, be sure to call its Close method.</br><br><b>Note</b>   If your application is relatively simple, consider using the AcceptTcpClient method rather than AcceptSocket. SecureTcpClient provides you with simple methods for sending and receiving data over a network.</br></remarks>
 public virtual SecureSocket AcceptSocket(CancellationToken cancel, ISocketMonitor monitor = null)
 {
     if (Server == null)
         throw new InvalidOperationException();
     return (SecureSocket)Server.Accept(cancel, monitor);
 }
コード例 #4
0
 /// <summary>
 /// Creates a new <see cref="SecureSocket"/> to handle an incoming connection request.
 /// </summary>
 /// <returns>A SecureSocket to handle an incoming connection request.</returns>
 /// <remarks>The returned <see cref="VirtualSocket"/> can be cast to a SecureSocket if necessary.</remarks>
 /// <exception cref="SocketException">An operating system error occurs while accessing the SecureSocket.</exception>
 /// <exception cref="ObjectDisposedException">The SecureSocket has been closed.</exception>
 /// <exception cref="SecurityException">Unable to create the credentials.</exception>
 public override VirtualSocket Accept(CancellationToken cancel, ISocketMonitor monitor = null)
 {
     return EndAccept(BeginAccept(null, null), cancel, monitor);
 }
コード例 #5
0
        /// <summary>
        /// Establishes a connection to a remote device and optionally negotiates a secure transport protocol.
        /// </summary>
        /// <param name="remoteEP">An <see cref="EndPoint"/> that represents the remote device.</param>
        /// <exception cref="ArgumentNullException">The remoteEP parameter is a null reference (<b>Nothing</b> in Visual Basic).</exception>
        /// <exception cref="SocketException">An operating system error occurs while accessing the <see cref="SecureSocket"/>.</exception>
        /// <exception cref="ObjectDisposedException">The SecureSocket has been closed.</exception>
        /// <exception cref="SecurityException">The security negotiation failed.</exception>
        public override void Connect(EndPoint remoteEP, ISocketMonitor monitor = null)
        {
            if (SecureProtocol == SecureProtocol.None)
            {
                base.Connect(remoteEP);
            }
            else
            {
                if (monitor != null)
                    monitor.Attach(this);

                this.EndConnect(this.BeginConnect(remoteEP, null, null));
            }
        }
コード例 #6
0
ファイル: VirtualSocket.cs プロジェクト: nunnun/http2-katana
 /// <summary>
 /// Ends an asynchronous request to create a new VirtualSocket to accept an incoming connection request.
 /// </summary>
 /// <param name="asyncResult">Stores state information for this asynchronous operation as well as any user defined data.</param>
 /// <returns>A VirtualSocket to handle the incoming connection.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
 /// <exception cref="ArgumentException"><paramref name="asyncResult"/> was not created by a call to <see cref="BeginAccept"/>.</exception>
 /// <exception cref="SocketException">An operating system error occurs while accessing the VirtualSocket.</exception>
 /// <exception cref="ObjectDisposedException">The VirtualSocket has been closed.</exception>
 /// <remarks>The EndAccept method completes a request for a connection that was started with the BeginAccept method.</remarks>
 public virtual VirtualSocket EndAccept(IAsyncResult asyncResult, ISocketMonitor monitor = null)
 {
     this.Monitor = monitor;
     return new VirtualSocket(InternalEndAccept(asyncResult));
 }
コード例 #7
0
ファイル: VirtualSocket.cs プロジェクト: nunnun/http2-katana
 /// <summary>
 /// Establishes a connection to a remote device.
 /// </summary>
 /// <param name="remoteEP">An <see cref="EndPoint"/> that represents the remote device.</param>
 /// <exception cref="ArgumentNullException"><paramref name="remoteEP"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
 /// <exception cref="SocketException">An operating system error occurs while accessing the VirtualSocket.</exception>
 /// <exception cref="ObjectDisposedException">The VirtualSocket has been closed.</exception>
 /// <remarks>The Connect method establishes a network connection between <see cref="LocalEndPoint"/> and the device identified by <paramref name="remoteEP"/>. Once the connection has been made, you can send data to the remote device with the <see cref="Send"/> method, or receive data from the remote device with the <see cref="Receive"/> method.</remarks>
 public virtual void Connect(EndPoint remoteEP, ISocketMonitor monitor = null)
 {
     this.Monitor = monitor;
     InternalSocket.Connect(remoteEP);
 }
コード例 #8
0
ファイル: VirtualSocket.cs プロジェクト: nunnun/http2-katana
 /// <summary>
 /// Creates a new VirtualSocket to handle an incoming connection request.
 /// </summary>
 /// <returns>A VirtualSocket to handle an incoming connection request.</returns>
 /// <exception cref="SocketException">The VirtualSocket is invalid.</exception>
 /// <exception cref="ObjectDisposedException">The VirtualSocket has been closed.</exception>
 /// <remarks>The Accept method extracts the first connection request from the queue of pending requests and creates a new VirtualSocket to handle it.</remarks>
 public virtual VirtualSocket Accept(ISocketMonitor monitor = null)
 {
     this.Monitor = monitor;
     return new VirtualSocket(InternalAccept());
 }
コード例 #9
0
 /// <summary>
 /// Creates a new VirtualSocket to handle an incoming connection request.
 /// </summary>
 /// <returns>A VirtualSocket to handle an incoming connection request.</returns>
 /// <exception cref="SocketException">The VirtualSocket is invalid.</exception>
 /// <exception cref="ObjectDisposedException">The VirtualSocket has been closed.</exception>
 /// <remarks>The Accept method extracts the first connection request from the queue of pending requests and creates a new VirtualSocket to handle it.</remarks>
 public virtual VirtualSocket Accept(CancellationToken cancel, ISocketMonitor monitor = null)
 {
     this.Monitor = monitor;
     return new VirtualSocket(InternalAccept());
 }
コード例 #10
0
ファイル: SecureSocket.cs プロジェクト: nunnun/http2-katana
 /// <summary>
 /// Creates a new <see cref="SecureSocket"/> to handle an incoming connection request.
 /// </summary>
 /// <returns>A SecureSocket to handle an incoming connection request.</returns>
 /// <remarks>The returned <see cref="VirtualSocket"/> can be cast to a SecureSocket if necessary.</remarks>
 /// <exception cref="SocketException">An operating system error occurs while accessing the SecureSocket.</exception>
 /// <exception cref="ObjectDisposedException">The SecureSocket has been closed.</exception>
 /// <exception cref="SecurityException">Unable to create the credentials.</exception>
 public override VirtualSocket Accept(ISocketMonitor monitor = null)
 {
     return EndAccept(BeginAccept(null, null), monitor);
 }