TCP/IP Sockets in C#: Practical Guide for Programmers (The Practical Guides)

TCP/IP Sockets in C#: Practical Guide for Programmers (The Practical Guides)

Michael J. Donahoo, Kenneth L. Calvert

Language: English

Pages: 175

ISBN: 0124660517

Format: PDF / Kindle (mobi) / ePub


"TCP/IP sockets in C# is an excellent book for anyone interested in writing network applications using Microsoft .Net frameworks. It is a unique combination of well written concise text and rich carefully selected set of working examples. For the beginner of network programming, it's a good starting book; on the other hand professionals could also take advantage of excellent handy sample code snippets and material on topics like message parsing and asynchronous programming."
Adarsh Khare, SDT, .Net Frameworks Team, Microsoft Corporation

The popularity of the C# language and the .NET framework is ever rising due to its ease of use, the extensive class libraries available in the .NET Framework, and the ubiquity of the Microsoft Windows operating system, to name a few advantages. TCP/IP Sockets in C# focuses on the Sockets API, the de facto standard for writing network applications in any programming language. Starting with simple client and server programs that use TCP/IP (the Internet protocol suite), students and practitioners quickly learn the basics and move on to firsthand experience with advanced topics including non-blocking sockets, multiplexing, threads, asynchronous programming, and multicasting. Key network programming concepts such as framing, performance and deadlocks are illustrated through hands-on examples. Using a detailed yet clear, concise approach, this book includes numerous code examples and focused discussions to provide a solid understanding of programming TCP/IP sockets in C#.

Features
*Tutorial-based instruction in key sockets programming techniques complemented by numerous code examples throughout
*Discussion moves quickly into the C# Sockets API definition and code examples, desirable for those who want to get up-to-speed quickly
*Important coverage of "under the hood" details that developers will find useful when creating and using a socket or a higher level TCP class that utilizes sockets
*Includes end-of-chapter exercises to facilitate learning, as well as sample code available for download at the book’s companion web site

*Tutorial-based instruction in key sockets programming techniques complemented by numerous code examples throughout

*Discussion moves quickly into the C# Sockets API definition and code examples, desirable for those who want to get up-to-speed quickly

*Important coverage of "under the hood" details that developers will find useful when creating and using a socket or a higher level TCP class that utilizes sockets

*Includes end-of-chapter exercises to facilitate learning, as well as sample code available for download at the book's companion web site

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

throw new ArgumentException("Parameters: []"); int servPort = (args.Length == 1) ? Int32.Parse(args[0]): 7; ■ 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 2.5 The .NET Socket Class 41 Socket server = null; try { // Create a socket to accept client connections server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); server.Bind(new IPEndPoint(IPAddress.Any, servPort));

between the programming constructs and the underlying protocol implementations in somewhat more detail. Our general approach introduces programming concepts through simple program examples accompanied by line-by-line commentary that describes the purpose of every part of the program. This lets you see the important objects and methods as they are used in context. As you look at the code, you should be able to understand the purpose of each and every line of code. Our examples do not take

encoding. ItemQuoteEncoderText.cs 0 using System; // For String, Activator 1 using System.IO; // For IOException 2 using System.Text; // For Encoding 3 4 public class ItemQuoteEncoderText : ItemQuoteEncoder { 5 6 public Encoding encoding; // Character encoding 7 8 public ItemQuoteEncoderText() : this(ItemQuoteTextConst.DEFAULT_CHAR_ENC) { 9 } 10 11 public ItemQuoteEncoderText(string encodingDesc) { 12 13 encoding = Encoding.GetEncoding(encodingDesc); } 14 15 public byte[]

typically involve some busy-waiting and are not very efficient. Better methods to implement this are discussed with Select() (Section 4.2), threads (Section 4.3), and asynchronous I/O (Section 4.4) Here we present a version of the TcpEchoClient.cs program from Chapter 2 that has been modified to use a nonblocking socket. An alternative version that utilizes the Poll() method instead is also available on the book’s website (www.mkp.com/practical/ csharpsockets). ■ 4.1 Nonblocking I/O 93

of, 63 C Callback, 117 Clients description of, 5–6 TCP, 17–23 UDP, 29–32 Closing connections description of, 138–145 TCP, 160–165 Communication channel, 1–2 Connection-oriented protocol, 3 ConsoleLogger, 105–106 D Datagram service, 3 Datagram sockets, 6 Deadlock, 152–154 Delegate, 117 Delimiter, 67 Demultiplexing, 165–167 Descriptor, 7 Destination address, 9 Directory services, 6 DNS, see Domain name system Dns class, 9–10 Domain name system, 5 Domain names, 5 Dotted-quad notation, 4 E EBCDIC,

Download sample

Download