Introduction to Nonblocking Sockets

Nonblocking System Architecture

  • Server: the application receiving requests.
  • Client: the set of applications sending requests to the server.
  • Socket channel: the communication channel between client and server. It is identified by the server IP address and the port number. Data passes through the socket channel by buffer items.
  • Selector: the main object of all nonblocking technology. It monitors the recorded socket channels and serializes the requests, which the server has to satisfy.
  • Keys: the objects used by the selector to sort the requests. Each key represents a single client sub-request and contains information to identify the client and the type of the request.

Figure 1 illustrates the architecture of a system using nonblocking sockets.

Figure 1. Nonblocking socket architecture

As you may notice, client applications simultaneously perform requests to the server. The selector collects them, creates the keys, and sends them to the server. This may seem like a blocking system, because the requests are processed one at a time; actually, it is not like that. In fact, each key doesn’t represent the entire information stream a client sends to a server, but just a part. We don’t have to forget the selector divides the client-data in sub-requests identified by the keys. Consequently, if more clients continuously send data to the server, the selector will create more keys, which will be processed according to a time-sharing policy. To emphasize that, in Figure 1 the keys have the same color of their related clients.

Pages: 1 2 3 4 5

One response to this post.

  1. uesful thoughts! thank you very much

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: