O'Reilly logo

TCP/IP Sockets in C# by Kenneth L. Calvert, Michael J. Donahoo, David Makofske

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

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 ...

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