Chapter 4 Beyond the Basics

The client and server examples in Chapter 2 demonstrate the basic model for programming with sockets in C#. The next step is to apply these concepts in various programming models, such as nonblocking I/O, threading, asynchronous I/O, and multicasting.

4.1 Nonblocking I/O

Socket I/O calls may block for several reasons. Data input methods Read(), Receive(), and ReceiveFrom() block if data is not available. Data output methods Write(), Send(), or SendTo() may block if there is not sufficient space to buffer the transmitted data. The Accept(), AcceptSocket(), and AcceptTcpClient() methods of the Socket and TcpListener classes all block until a connection has been established (see Section 5.4). Meanwhile, long round-trip ...

Get TCP/IP Sockets in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.