TaskDatagramChannel

abstract class TaskDatagramChannel

A Task based asynchronous channel for reading, writing, and manipulating an UDP socket.

On the JVM this is a wrapper around java.nio.channels.DatagramChannel

Example
 val ch = TaskDatagramChannel()
 ch
   .send(Packet("Hello world!".getBytes("UTF-8")), new InetSocketAddress("localhost", 2115)))
   .map { len =>
     println(len)
     ch.close()
   }
   .runAsync
Companion
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def bind(local: InetSocketAddress): Task[Unit]

Binds the channel's socket to a local address

Binds the channel's socket to a local address

Value Params
local

the local address to bind the socket, or null to bind to an automatically assigned socket address

def close(): Task[Unit]

$closeDesc

$closeDesc

def localAddress(): Task[Option[InetSocketAddress]]

Asks the socket address that this channel's socket is bound to

Asks the socket address that this channel's socket is bound to

def receive(maxSize: Int, timeout: FiniteDuration): Task[Option[Packet]]

Receives a packet via this channel. If a datagram is not available after the timeout then this method returns scala.None.

Receives a packet via this channel. If a datagram is not available after the timeout then this method returns scala.None.

Value Params
maxSize

if the value is smaller than the size required to hold the datagram, then the remainder of the datagram is silently discarded.

timeout

the receive timeout

Returns

the packet, or scala.None if no datagram was available before timeout

def send(packet: Packet): Task[Int]

Sends a datagram via this channel

Sends a datagram via this channel

Value Params
packet

the packet to be sent