equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Sun designates this |
7 * published by the Free Software Foundation. Sun designates this |
29 import java.net.ProtocolFamily; |
29 import java.net.ProtocolFamily; |
30 import java.net.DatagramSocket; |
30 import java.net.DatagramSocket; |
31 import java.net.SocketOption; |
31 import java.net.SocketOption; |
32 import java.net.SocketAddress; |
32 import java.net.SocketAddress; |
33 import java.nio.ByteBuffer; |
33 import java.nio.ByteBuffer; |
34 import java.nio.channels.spi.*; |
34 import java.nio.channels.spi.AbstractSelectableChannel; |
|
35 import java.nio.channels.spi.SelectorProvider; |
35 |
36 |
36 /** |
37 /** |
37 * A selectable channel for datagram-oriented sockets. |
38 * A selectable channel for datagram-oriented sockets. |
38 * |
39 * |
39 * <p> A datagram channel is created by invoking one of the {@link #open open} methods |
40 * <p> A datagram channel is created by invoking one of the {@link #open open} methods |
51 * <p> Once connected, a datagram channel remains connected until it is |
52 * <p> Once connected, a datagram channel remains connected until it is |
52 * disconnected or closed. Whether or not a datagram channel is connected may |
53 * disconnected or closed. Whether or not a datagram channel is connected may |
53 * be determined by invoking its {@link #isConnected isConnected} method. |
54 * be determined by invoking its {@link #isConnected isConnected} method. |
54 * |
55 * |
55 * <p> Socket options are configured using the {@link #setOption(SocketOption,Object) |
56 * <p> Socket options are configured using the {@link #setOption(SocketOption,Object) |
56 * setOption} method. Datagram channels support the following options: |
57 * setOption} method. A datagram channel to an Internet Protocol socket supports |
|
58 * the following options: |
57 * <blockquote> |
59 * <blockquote> |
58 * <table border> |
60 * <table border> |
59 * <tr> |
61 * <tr> |
60 * <th>Option Name</th> |
62 * <th>Option Name</th> |
61 * <th>Description</th> |
63 * <th>Description</th> |
209 */ |
211 */ |
210 public abstract DatagramChannel bind(SocketAddress local) |
212 public abstract DatagramChannel bind(SocketAddress local) |
211 throws IOException; |
213 throws IOException; |
212 |
214 |
213 /** |
215 /** |
|
216 * @throws UnsupportedOperationException {@inheritDoc} |
214 * @throws IllegalArgumentException {@inheritDoc} |
217 * @throws IllegalArgumentException {@inheritDoc} |
215 * @throws ClosedChannelException {@inheritDoc} |
218 * @throws ClosedChannelException {@inheritDoc} |
216 * @throws IOException {@inheritDoc} |
219 * @throws IOException {@inheritDoc} |
217 * |
220 * |
218 * @since 1.7 |
221 * @since 1.7 |
219 */ |
222 */ |
220 public abstract <T> DatagramChannel setOption(SocketOption<T> name, T value) |
223 public abstract <T> DatagramChannel setOption(SocketOption<T> name, T value) |
221 throws IOException; |
224 throws IOException; |
222 |
|
223 |
225 |
224 /** |
226 /** |
225 * Retrieves a datagram socket associated with this channel. |
227 * Retrieves a datagram socket associated with this channel. |
226 * |
228 * |
227 * <p> The returned object will not declare any public methods that are not |
229 * <p> The returned object will not declare any public methods that are not |
311 public abstract DatagramChannel disconnect() throws IOException; |
313 public abstract DatagramChannel disconnect() throws IOException; |
312 |
314 |
313 /** |
315 /** |
314 * Returns the remote address to which this channel's socket is connected. |
316 * Returns the remote address to which this channel's socket is connected. |
315 * |
317 * |
316 * @return The remote address; {@code null} if the channel is not {@link |
318 * @return The remote address; {@code null} if the channel's socket is not |
317 * #isOpen open} or the channel's socket is not connected |
319 * connected |
318 * |
320 * |
|
321 * @throws ClosedChannelException |
|
322 * If the channel is closed |
319 * @throws IOException |
323 * @throws IOException |
320 * If an I/O error occurs |
324 * If an I/O error occurs |
321 * |
325 * |
322 * @since 1.7 |
326 * @since 1.7 |
323 */ |
327 */ |
324 public abstract SocketAddress getConnectedAddress() throws IOException; |
328 public abstract SocketAddress getRemoteAddress() throws IOException; |
325 |
329 |
326 /** |
330 /** |
327 * Receives a datagram via this channel. |
331 * Receives a datagram via this channel. |
328 * |
332 * |
329 * <p> If a datagram is immediately available, or if this channel is in |
333 * <p> If a datagram is immediately available, or if this channel is in |