Skip to content

Commit 54e1018

Browse files
authored
topic fixes (#6413)
* topic fixes * Update service-channel-listeners-and-channels.md
1 parent 3a83bce commit 54e1018

File tree

1 file changed

+45
-40
lines changed

1 file changed

+45
-40
lines changed
Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
11
---
2-
title: "Service: Channel Listeners and Channels"
2+
title: "Service: Channel listeners and channels"
33
ms.date: "03/30/2017"
44
ms.assetid: 8ccbe0e8-7e55-441d-80de-5765f67542fa
55
---
6-
# Service: Channel Listeners and Channels
7-
There are three categories of channel objects: channels, channel listeners and channel factories. Channels are the interface between the application and the channel stack. Channel listeners are responsible for creating channels on the receive (or listen) side, typically in response to a new incoming message or connection. Channel factories are responsible for creating channels on the send side to initiate communication with an endpoint.
8-
9-
## Channel Listeners and Channels
10-
Channel listeners are responsible for creating channels and receiving messages from the layer below or from the network. Received messages are delivered to the layer above using a channel that is created by the channel listener.
11-
12-
The following diagram illustrates the process of receiving messages and delivering them to the layer above.
13-
14-
![Channel listeners and channels](../../../../docs/framework/wcf/extending/media/wcfc-wcfchannelsigure1highlevelc.gif "wcfc_WCFChannelsigure1HighLevelc")
15-
A channel listener receiving messages and delivering to the layer above through channels.
16-
17-
The process can be conceptually modeled as a queue inside each channel although the implementation may not actually use a queue. The channel listener is responsible for receiving messages from the layer below or the network and putting them in the queue. The channel is responsible for getting messages from the queue and handing them to the layer above when that layer asks for a message, for example by calling `Receive` on the channel.
18-
19-
WCF provides base class helpers for this process. (For a diagram of the channel helper classes discussed in this topic, see [Channel Model Overview](../../../../docs/framework/wcf/extending/channel-model-overview.md).)
20-
21-
- The <xref:System.ServiceModel.Channels.CommunicationObject> class implements <xref:System.ServiceModel.ICommunicationObject> and enforces the state machine described in step 2 of [Developing Channels](../../../../docs/framework/wcf/extending/developing-channels.md).
22-
23-
- The <xref:System.ServiceModel.Channels.ChannelManagerBase> class implements <xref:System.ServiceModel.Channels.CommunicationObject> and provides a unified base class for <xref:System.ServiceModel.Channels.ChannelFactoryBase> and <xref:System.ServiceModel.Channels.ChannelListenerBase>. The <xref:System.ServiceModel.Channels.ChannelManagerBase> class works in conjunction with <xref:System.ServiceModel.Channels.ChannelBase>, which is a base class that implements <xref:System.ServiceModel.Channels.IChannel>.
24-
25-
- The``<xref:System.ServiceModel.Channels.ChannelFactoryBase> class implements <xref:System.ServiceModel.Channels.ChannelManagerBase> and <xref:System.ServiceModel.Channels.IChannelFactory> and consolidates the `CreateChannel` overloads into one `OnCreateChannel` abstract method.
26-
27-
- The <xref:System.ServiceModel.Channels.ChannelListenerBase> class implements <xref:System.ServiceModel.Channels.IChannelListener>. It takes care of basic state management.
28-
29-
The following discussion is based upon the [Transport: UDP](../../../../docs/framework/wcf/samples/transport-udp.md) sample.
30-
31-
## Creating a Channel Listener
32-
The``UdpChannelListener that the sample implements derives from the <xref:System.ServiceModel.Channels.ChannelListenerBase> class. It uses a single UDP socket to receive datagrams. The `OnOpen` method receives data using the UDP socket in an asynchronous loop. The data are then converted into messages using the message encoding system:
33-
34-
```
35-
message = UdpConstants.MessageEncoder.ReadMessage(
36-
new ArraySegment<byte>(buffer, 0, count),
37-
bufferManager
38-
);
39-
```
40-
41-
Because the same datagram channel represents messages that arrive from a number of sources, the `UdpChannelListener` is a singleton listener. There is at most one active <xref:System.ServiceModel.Channels.IChannel>``associated with this listener at a time. The sample generates another one only if a channel that is returned by the <xref:System.ServiceModel.Channels.ChannelListenerBase%601.AcceptChannel%2A> method is subsequently disposed. When a message is received, it is enqueued into this singleton channel.
42-
43-
### UdpInputChannel
44-
The `UdpInputChannel` class implements <xref:System.ServiceModel.Channels.IInputChannel>. It consists of a queue of incoming messages that is populated by the `UdpChannelListener`'s socket. These messages are dequeued by the <xref:System.ServiceModel.Channels.IInputChannel.Receive%2A> method.
6+
# Service: Channel listeners and channels
7+
8+
There are three categories of channel objects: channels, channel listeners, and channel factories. Channels are the interface between the application and the channel stack. Channel listeners are responsible for creating channels on the receive (or listen) side, typically in response to a new incoming message or connection. Channel factories are responsible for creating channels on the send side to initiate communication with an endpoint.
9+
10+
## Channel listeners and channels
11+
12+
Channel listeners are responsible for creating channels and receiving messages from the layer below or from the network. Received messages are delivered to the layer above using a channel that is created by the channel listener.
13+
14+
The following diagram illustrates the process of receiving messages and delivering them to the layer above.
15+
16+
![Channel listeners and channels](./media/wcfc-wcfchannelsigure1highlevelc.gif "wcfc_WCFChannelsigure1HighLevelc")
17+
18+
A channel listener receiving messages and delivering to the layer above through channels.
19+
20+
The process can be conceptually modeled as a queue inside each channel although the implementation may not actually use a queue. The channel listener is responsible for receiving messages from the layer below or the network and putting them in the queue. The channel is responsible for getting messages from the queue and handing them to the layer above when that layer asks for a message, for example by calling `Receive` on the channel.
21+
22+
WCF provides base class helpers for this process. (For a diagram of the channel helper classes discussed in this article, see [Channel Model Overview](channel-model-overview.md).)
23+
24+
- The <xref:System.ServiceModel.Channels.CommunicationObject> class implements <xref:System.ServiceModel.ICommunicationObject> and enforces the state machine described in step 2 of [Developing Channels](developing-channels.md).
25+
26+
- The <xref:System.ServiceModel.Channels.ChannelManagerBase> class implements <xref:System.ServiceModel.Channels.CommunicationObject> and provides a unified base class for <xref:System.ServiceModel.Channels.ChannelFactoryBase> and <xref:System.ServiceModel.Channels.ChannelListenerBase>. The <xref:System.ServiceModel.Channels.ChannelManagerBase> class works in conjunction with <xref:System.ServiceModel.Channels.ChannelBase>, which is a base class that implements <xref:System.ServiceModel.Channels.IChannel>.
27+
28+
- The <xref:System.ServiceModel.Channels.ChannelFactoryBase> class implements <xref:System.ServiceModel.Channels.ChannelManagerBase> and <xref:System.ServiceModel.Channels.IChannelFactory> and consolidates the `CreateChannel` overloads into one `OnCreateChannel` abstract method.
29+
30+
- The <xref:System.ServiceModel.Channels.ChannelListenerBase> class implements <xref:System.ServiceModel.Channels.IChannelListener>. It takes care of basic state management.
31+
32+
The following discussion is based upon the [Transport: UDP](../../../../docs/framework/wcf/samples/transport-udp.md) sample.
33+
34+
## Creating a channel listener
35+
36+
The `UdpChannelListener` that the sample implements derives from the <xref:System.ServiceModel.Channels.ChannelListenerBase> class. It uses a single UDP socket to receive datagrams. The `OnOpen` method receives data using the UDP socket in an asynchronous loop. The data are then converted into messages using the message encoding system:
37+
38+
```csharp
39+
message = UdpConstants.MessageEncoder.ReadMessage(
40+
new ArraySegment<byte>(buffer, 0, count),
41+
bufferManager
42+
);
43+
```
44+
45+
Because the same datagram channel represents messages that arrive from a number of sources, the `UdpChannelListener` is a singleton listener. There is at most one active <xref:System.ServiceModel.Channels.IChannel> associated with this listener at a time. The sample generates another one only if a channel that is returned by the <xref:System.ServiceModel.Channels.ChannelListenerBase%601.AcceptChannel%2A> method is subsequently disposed. When a message is received, it's enqueued into this singleton channel.
46+
47+
### UdpInputChannel
48+
49+
The `UdpInputChannel` class implements <xref:System.ServiceModel.Channels.IInputChannel>. It consists of a queue of incoming messages that is populated by the `UdpChannelListener`'s socket. These messages are dequeued by the <xref:System.ServiceModel.Channels.IInputChannel.Receive%2A> method.

0 commit comments

Comments
 (0)