View Javadoc
1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel.socket;
17  
18  import io.netty.channel.Channel;
19  import io.netty.channel.ChannelFuture;
20  import io.netty.channel.ChannelPromise;
21  
22  import java.net.InetAddress;
23  import java.net.InetSocketAddress;
24  import java.net.NetworkInterface;
25  
26  /**
27   * A UDP/IP {@link Channel}}.
28   */
29  public interface DatagramChannel extends Channel {
30      @Override
31      DatagramChannelConfig config();
32      @Override
33      InetSocketAddress localAddress();
34      @Override
35      InetSocketAddress remoteAddress();
36  
37      /**
38       * Return {@code true} if the {@link DatagramChannel} is connected to the remote peer.
39       */
40      boolean isConnected();
41  
42      /**
43       * Joins a multicast group and notifies the {@link ChannelFuture} once the operation completes.
44       */
45      ChannelFuture joinGroup(InetAddress multicastAddress);
46  
47      /**
48       * Joins a multicast group and notifies the {@link ChannelFuture} once the operation completes.
49       *
50       * The given {@link ChannelFuture} will be notified and also returned.
51       */
52      ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise future);
53  
54      /**
55       * Joins the specified multicast group at the specified interface and notifies the {@link ChannelFuture}
56       * once the operation completes.
57       */
58      ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface);
59  
60      /**
61       * Joins the specified multicast group at the specified interface and notifies the {@link ChannelFuture}
62       * once the operation completes.
63       *
64       * The given {@link ChannelFuture} will be notified and also returned.
65       */
66      ChannelFuture joinGroup(
67              InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise future);
68  
69      /**
70       * Joins the specified multicast group at the specified interface and notifies the {@link ChannelFuture}
71       * once the operation completes.
72       */
73      ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source);
74  
75      /**
76       * Joins the specified multicast group at the specified interface and notifies the {@link ChannelFuture}
77       * once the operation completes.
78       *
79       * The given {@link ChannelFuture} will be notified and also returned.
80       */
81      ChannelFuture joinGroup(
82              InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise future);
83  
84      /**
85       * Leaves a multicast group and notifies the {@link ChannelFuture} once the operation completes.
86       */
87      ChannelFuture leaveGroup(InetAddress multicastAddress);
88  
89      /**
90       * Leaves a multicast group and notifies the {@link ChannelFuture} once the operation completes.
91       *
92       * The given {@link ChannelFuture} will be notified and also returned.
93       */
94      ChannelFuture leaveGroup(InetAddress multicastAddress, ChannelPromise future);
95  
96      /**
97       * Leaves a multicast group on a specified local interface and notifies the {@link ChannelFuture} once the
98       * operation completes.
99       */
100     ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface);
101 
102     /**
103      * Leaves a multicast group on a specified local interface and notifies the {@link ChannelFuture} once the
104      * operation completes.
105      *
106      * The given {@link ChannelFuture} will be notified and also returned.
107      */
108     ChannelFuture leaveGroup(
109             InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise future);
110 
111     /**
112      * Leave the specified multicast group at the specified interface using the specified source and notifies
113      * the {@link ChannelFuture} once the operation completes.
114      *
115      */
116     ChannelFuture leaveGroup(
117             InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source);
118 
119     /**
120      * Leave the specified multicast group at the specified interface using the specified source and notifies
121      * the {@link ChannelFuture} once the operation completes.
122      *
123      * The given {@link ChannelFuture} will be notified and also returned.
124      */
125     ChannelFuture leaveGroup(
126             InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source,
127             ChannelPromise future);
128 
129     /**
130      * Block the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies
131      * the {@link ChannelFuture} once the operation completes.
132      *
133      * The given {@link ChannelFuture} will be notified and also returned.
134      */
135     ChannelFuture block(
136             InetAddress multicastAddress, NetworkInterface networkInterface,
137             InetAddress sourceToBlock);
138 
139     /**
140      * Block the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies
141      * the {@link ChannelFuture} once the operation completes.
142      *
143      * The given {@link ChannelFuture} will be notified and also returned.
144      */
145     ChannelFuture block(
146             InetAddress multicastAddress, NetworkInterface networkInterface,
147             InetAddress sourceToBlock, ChannelPromise future);
148 
149     /**
150      * Block the given sourceToBlock address for the given multicastAddress and notifies the {@link ChannelFuture} once
151      * the operation completes.
152      *
153      * The given {@link ChannelFuture} will be notified and also returned.
154      */
155     ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock);
156 
157     /**
158      * Block the given sourceToBlock address for the given multicastAddress and notifies the {@link ChannelFuture} once
159      * the operation completes.
160      *
161      * The given {@link ChannelFuture} will be notified and also returned.
162      */
163     ChannelFuture block(
164             InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise future);
165 }