net-coroutines / org.apache.tuweni.net.coroutines / CoroutineDatagramChannel

CoroutineDatagramChannel

class CoroutineDatagramChannel : CoroutineByteChannel, ScatteringCoroutineByteChannel, GatheringCoroutineByteChannel, CoroutineNetworkChannel (source)

A co-routine based datagram-oriented network channel.

Author
Chris Leishman - https://cleishm.github.io/

Properties

isConnected

val isConnected: Boolean

Indicates whether this channel is connected.

remoteAddress

val remoteAddress: SocketAddress

Get the remote address to which this channel is connected.

Functions

bind

fun bind(local: SocketAddress?): CoroutineDatagramChannel

Binds the channel's socket to a local address.

close

fun close(): Unit

Closes this channel.

connect

fun connect(remote: SocketAddress): CoroutineDatagramChannel

Connect this channel.

disconnect

fun disconnect(): CoroutineDatagramChannel

Disconnects this channel.

receive

suspend fun receive(dst: ByteBuffer): SocketAddress

Receives a datagram via this channel.

send

suspend fun send(src: ByteBuffer, target: SocketAddress): Int

Sends a datagram via this channel.

tryReceive

fun tryReceive(dst: ByteBuffer): SocketAddress?

Receives a datagram via this channel, if one is immediately available.

trySend

fun trySend(src: ByteBuffer, target: SocketAddress): Int

Sends a datagram via this channel, if it can be sent immediately.

Companion Object Functions

open

fun open(group: CoroutineChannelGroup = CommonCoroutineGroup): CoroutineDatagramChannel

Opens a datagram channel.