Using a callback to handle the completion of a work item is very handy when creating a server
process that will handle incoming requests. For example, suppose you have a process that listens on
a specific TCP/IP port for an incoming request. When it receives one, it replies with the requested
information. To achieve high utilization, you definitely want to pend these operations asynchro-
nously. Consider the following example that listens on port 1234 and when it receives anything at
all, it simply replies with “Hello World!”:
using System;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
public class EntryPoint {
private const int CONNECT_QUEUE_LENGTH = 4;
private const int LISTEN_PORT = 1234;
static void ListenForRequests() ...