Acceptor-Connector

 

This article is extracted from POSA2 as a reading note.

Superserver implementations, for example Inetd, Listen, and the Service Configurator from the ACE framework, use a master acceptor process that listens for connections on set of communication ports. In Inetd, for example, each port is associated with a service, such as the standard Internet services FTP, TELNET, DAYTIME, and ECHO. The acceptor process decouples the functionality of the Inetd superserver into two separate parts: one for establishing connections and another for receiving and processing requests from peers. When a service request arrives on a port monitored by Inetd, it accepts the request and dispatches an appropriate pre-registered handler to perform the service.

The Acceptor-Connector design pattern decouples the connection and initialization of cooperating peer services in a networked system from the processing performed by the peer services after they are connected and initialized.

There are six key participants in the Acceptor-Connector pattern:

Passive mode transport endpoint: A passive mode transport endpoint is a factory that listens for connection requests to arrive, accepts those connection requests, and creates transport handlers that encapsulate the newly connected transport endpoints. Data can be exchanged via connected transport endpoints by reading and writing to their associated transport handles.

Service handler: A service handler defines one half of an end to end service in a networked system. A concrete service handler often plays either the client role or server role in this end to end service. In peer to peer use cases it can even play both roles simultaneously.

Acceptor: An acceptor is a factory that implements a strategy for passively establishing a connected transport endpoint, and creating and initializing its associated transport handle and service handler. An acceptor provides two methods, connection initialization and connection completion, that perform these steps with the help of a passive mode transport endpoint.

Connector: A connector is a factory that implements the strategy for actively establishing a connected transport endpoint and initializing its associated transport handle and service handler. It provides two methods, connection initialization and connection completion, that perform these steps.

Dispatcher: A dispatcher is responsible for demultiplexing indication events that represent various types of service requests, such as connection requests and data requests.

Concrete service handlers: Concrete service handlers define the application specific portions of end to end services. They are activated by concrete acceptors or concrete connectors. Concrete acceptors instantiate generic acceptors with concrete service handlers, transport endpoints, and transport handles used by these service handlers. Similarly, concrete connectors instantiate generic connectors.


 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值