Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

Name

TcpClient

Synopsis

This class provides a client-side abstraction of the sockets API. The zero-argument form of the constructor creates the client. Connect to a remote server with the Connect() method (you must specify an existing System.Net.IPEndPoint or a remote IP address and port number). Alternatively, use an overloaded form of the constructor to simultaneously create the client and make the connection.

This class completely obscures the underlying socket. However, the GetStream() method returns a NetworkStream that you can use to send and receive data across the network.

public class TcpClient : IDisposable {
// Public Constructors
   public method TcpClient();  
   public method TcpClient(System.Net.IPEndPoint localEP);  
   public method TcpClient(string hostname, int port);  
// Public Instance Properties
   public field LingerOption LingerState{set; get; } 
   public field bool NoDelay{set; get; } 
   public field int ReceiveBufferSize{set; get; } 
   public field int ReceiveTimeout{set; get; } 
   public field int SendBufferSize{set; get; } 
   public field int SendTimeout{set; get; } 
// Protected Instance Properties
   protected field bool Active{set; get; } 
   protected field Socket Client{set; get; } 
// Public Instance Methods
   public method void Close();  
   public method void Connect(System.Net.IPAddress address, 
        int port);  
   public method void Connect(
        System.Net.IPEndPoint remoteEP);  
   public method void Connect(string hostname, int port);  
   public method NetworkStream GetStream();  
// Protected Instance Methods ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata