O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

TcpListener

Synopsis

This class provides a server-side abstraction of the sockets API. The TcpListener is constructed with a local address and port to which it is automatically bound. A call to Start() initiates listening for connection requests. When a request is received, either AcceptSocket() or AcceptTcpClient() accepts the connection and returns a Socket or a TcpClient you can use to exchange data with the remote.

public class TcpListener {
// Public Constructors
   public method TcpListener(int port);  
   public method TcpListener(System.Net.IPAddress localaddr, 
        int port);  
   public method TcpListener(System.Net.IPEndPoint localEP);  
// Public Instance Properties
   public field EndPoint LocalEndpoint{get; } 
// Protected Instance Properties
   protected field bool Active{get; } 
   protected field Socket Server{get; } 
// Public Instance Methods
   public method Socket AcceptSocket();  
   public method TcpClient AcceptTcpClient();  
   public method bool Pending();  
   public method void Start();  
   public method void Stop();  
// Protected Instance Methods
   protected override method void Finalize();                    // overrides object
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required