Пример #1
0
        /// <summary>Asynchronously accepts an incoming connection attempt and creates a new <see cref="T:System.Net.Sockets.TcpClient" /> to handle remote host communication.</summary>
        /// <returns>A <see cref="T:System.Net.Sockets.TcpClient" />.</returns>
        /// <param name="asyncResult">An <see cref="T:System.IAsyncResult" /> returned by a call to the <see cref="M:System.Net.Sockets.TcpListener.BeginAcceptTcpClient(System.AsyncCallback,System.Object)" /> method.</param>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
        ///   <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        /// </PermissionSet>
        public TcpClient EndAcceptTcpClient(IAsyncResult asyncResult)
        {
            Socket    tcpClient  = this.server.EndAccept(asyncResult);
            TcpClient tcpClient2 = new TcpClient();

            tcpClient2.SetTcpClient(tcpClient);
            return(tcpClient2);
        }
Пример #2
0
        public TcpClient EndAcceptTcpClient(IAsyncResult asyncResult)
        {
            Socket    clientSocket = server.EndAccept(asyncResult);
            TcpClient client       = new TcpClient();

            client.SetTcpClient(clientSocket);

            return(client);
        }
Пример #3
0
        public TcpClient AcceptTcpClient()
        {
            if (!this.active)
            {
                throw new InvalidOperationException("Socket is not listening");
            }
            Socket    s      = this.server.Accept();
            TcpClient client = new TcpClient();

            client.SetTcpClient(s);
            return(client);
        }
Пример #4
0
        /// <summary>Accepts a pending connection request </summary>
        /// <returns>A <see cref="T:System.Net.Sockets.TcpClient" /> used to send and receive data.</returns>
        /// <exception cref="T:System.InvalidOperationException">The listener has not been started with a call to <see cref="M:System.Net.Sockets.TcpListener.Start" />. </exception>
        /// <exception cref="T:System.Net.Sockets.SocketException">Use the <see cref="P:System.Net.Sockets.SocketException.ErrorCode" /> property to obtain the specific error code. When you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
        ///   <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        /// </PermissionSet>
        public TcpClient AcceptTcpClient()
        {
            if (!this.active)
            {
                throw new InvalidOperationException("Socket is not listening");
            }
            Socket    tcpClient  = this.server.Accept();
            TcpClient tcpClient2 = new TcpClient();

            tcpClient2.SetTcpClient(tcpClient);
            return(tcpClient2);
        }
Пример #5
0
        /// <summary>
        /// Accepts a pending connection
        /// </summary>
        /// <returns>A TcpClient
        /// object made from the new socket.</returns>
        public TcpClient AcceptTcpClient()
        {
            if (!active)
            {
                throw new InvalidOperationException("Socket is not listening");
            }

            Socket clientSocket = server.Accept();

            TcpClient client = new TcpClient();

            // use internal method SetTcpClient to make a
            // client with the specified socket
            client.SetTcpClient(clientSocket);

            return(client);
        }
Пример #6
0
		public TcpClient EndAcceptTcpClient (IAsyncResult asyncResult)
		{
			Socket clientSocket = server.EndAccept (asyncResult);
			TcpClient client = new TcpClient ();
			
			client.SetTcpClient (clientSocket);
			
			return(client);
		}
Пример #7
0
		/// <summary>
		/// Accepts a pending connection
		/// </summary>
		/// <returns>A TcpClient
		/// object made from the new socket.</returns>
		public TcpClient AcceptTcpClient ()
		{
			if (!active)
				throw new InvalidOperationException ("Socket is not listening");

			Socket clientSocket = server.Accept ();

			TcpClient client = new TcpClient();
			// use internal method SetTcpClient to make a
			// client with the specified socket
			client.SetTcpClient (clientSocket);
			
			return client;
		}
Пример #8
0
 public TcpClient AcceptTcpClient()
 {
     if (!this.active)
     {
         throw new InvalidOperationException("Socket is not listening");
     }
     Socket s = this.server.Accept();
     TcpClient client = new TcpClient();
     client.SetTcpClient(s);
     return client;
 }