Android Guides | Samples

Java.Nio.Channels.DatagramChannel Class

A DatagramChannel is a selectable channel that represents a partial abstraction of a datagram socket.

See Also: DatagramChannel

Syntax

[Android.Runtime.Register("java/nio/channels/DatagramChannel", DoNotGenerateAcw=true)]
public abstract class DatagramChannel : AbstractSelectableChannel, IByteChannel, IGatheringByteChannel, IScatteringByteChannel, IDisposable

Remarks

A DatagramChannel is a selectable channel that represents a partial abstraction of a datagram socket. The socket method of this class can return the related DatagramSocket instance, which can handle the socket.

A datagram channel is open but not connected when created with the open() method. After it is connected, it will keep the connected status until it is disconnected or closed. The benefit of a connected channel is the reduced effort of security checks during send and receive. When invoking read or write, a connected channel is required.

Datagram channels are thread-safe; only one thread can read or write at the same time.

[Android Documentation]

Requirements

Namespace: Java.Nio.Channels
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Java.Nio.Channels.DatagramChannel are listed below.

See Also: AbstractSelectableChannel

Protected Constructors

Constructs a new DatagramChannel.
A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
abstract
IsConnectedBoolean. Returns whether this channel's socket is connected or not.
[read-only]
abstract
RemoteAddressSocketAddress.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

abstract
Bind(SocketAddress) : DatagramChannel
abstract
Connect(SocketAddress) : DatagramChannel
Connects the socket of this channel to a remote address, which is the only communication peer for getting and sending datagrams after being connected.
ConnectAsync(SocketAddress) : System.Threading.Tasks.Task<DatagramChannel>
abstract
Disconnect() : DatagramChannel
Disconnects the socket of this channel, which has been connected before in order to send and receive datagrams.
static
Open() : DatagramChannel
Creates an opened and not-connected datagram channel.
abstract
Read(ByteBuffer) : Int32
Reads a datagram from this channel into the byte buffer.
Read(ByteBuffer[]) : Int64
Reads a datagram from this channel into an array of byte buffers.
abstract
Read(ByteBuffer[], Int32, Int32) : Int64
Reads a datagram from this channel into an array of byte buffers.
abstract
Receive(ByteBuffer) : SocketAddress
Gets a datagram from this channel.
ReceiveAsync(ByteBuffer) : System.Threading.Tasks.Task<Java.Net.SocketAddress>
abstract
Send(ByteBuffer, SocketAddress) : Int32
Sends a datagram through this channel.
SendAsync(ByteBuffer, SocketAddress) : System.Threading.Tasks.Task<int>
abstract
Socket() : DatagramSocket
Returns the related datagram socket of this channel, which does not define additional public methods to those defined by DatagramSocket.
override
ValidOps() : Operations
Gets the valid operations of this channel.
abstract
Write(ByteBuffer) : Int32
Writes a datagram from the byte buffer to this channel.
Write(ByteBuffer[]) : Int64
Writes a datagram from the byte buffers to this channel.
abstract
Write(ByteBuffer[], Int32, Int32) : Int64
Writes a datagram from the byte buffers to this channel.