GeezerVison is showing docs.oracle.com — DatagramChannel (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.nio.channels
Class DatagramChannel
-
- All Implemented Interfaces:
- Closeable, AutoCloseable, ByteChannel, Channel, GatheringByteChannel, InterruptibleChannel, MulticastChannel, NetworkChannel, ReadableByteChannel, ScatteringByteChannel, WritableByteChannel
public abstract class DatagramChannel
extends AbstractSelectableChannel
implements ByteChannel, ScatteringByteChannel, GatheringByteChannel, MulticastChannel
A selectable channel for datagram-oriented sockets.
A datagram channel is created by invoking one of the open methods
of this class. It is not possible to create a channel for an arbitrary,
pre-existing datagram socket. A newly-created datagram channel is open but not
connected. A datagram channel need not be connected in order for the send and receive methods to be used. A datagram channel may be
connected, by invoking its connect method, in order to
avoid the overhead of the security checks are otherwise performed as part of
every send and receive operation. A datagram channel must be connected in
order to use the read and write methods, since those methods do not
accept or return socket addresses.
Once connected, a datagram channel remains connected until it is
disconnected or closed. Whether or not a datagram channel is connected may
be determined by invoking its isConnected method.
Socket options are configured using the setOption method. A datagram channel to an Internet Protocol socket supports
the following options:
| Option Name |
Description |
SO_SNDBUF |
The size of the socket send buffer |
SO_RCVBUF |
The size of the socket receive buffer |
SO_REUSEADDR |
Re-use address |
SO_BROADCAST |
Allow transmission of broadcast datagrams |
IP_TOS |
The Type of Service (ToS) octet in the Internet Protocol (IP) header |
IP_MULTICAST_IF |
The network interface for Internet Protocol (IP) multicast datagrams |
IP_MULTICAST_TTL |
The time-to-live for Internet Protocol (IP) multicast
datagrams |
IP_MULTICAST_LOOP |
Loopback for Internet Protocol (IP) multicast datagrams |
Additional (implementation specific) options may also be supported.
Datagram channels are safe for use by multiple concurrent threads. They
support concurrent reading and writing, though at most one thread may be
reading and at most one thread may be writing at any given time.
- Since:
- 1.4
-
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.nio.channels.Channel
isOpen
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|