tango.net.device.Datagram

License:

BSD style: see license.txt

Version:

Mar 2004 : Initial release

Version:

Dec 2006 : South Pacific release

Author:

Kris
class Datagram : Socket #
Datagrams provide a low-overhead, non-reliable data transmission mechanism.
Datagrams are not 'connected' in the same manner as a TCP socket; you don't need to listen() or accept() to receive a datagram, and data may arrive from multiple sources. A datagram socket may, however, still use the connect() method like a TCP socket. When connected, the read() and write() methods will be restricted to a single address rather than being open instead. That is, applying connect() will make the address argument to both read() and write() irrelevant. Without connect(), method write() must be supplied with an address and method read() should be supplied with one to identify where data originated. Note that when used as a listener, you must first bind the socket to a local adapter. This can be achieved by binding the socket to an InternetAddress constructed with a port only (ADDR_ANY), thus requesting the OS to assign the address of a local network adapter
this() #
Create a read/write datagram socket
size_t read(void[] src) [override] #
Populate the provided array from the socket. This will stall until some data is available, or a timeout occurs. We assume the datagram has been connected.
Returns the number of bytes read to the output, or Eof if the socket cannot read
size_t read(void[] dst, Address from) #
Read bytes from an available datagram into the given array. When provided, the 'from' address will be populated with the origin of the incoming data. Note that we employ the timeout mechanics exposed via our Socket superclass.
Returns the number of bytes read from the input, or Eof if the socket cannot read
size_t write(void[] src) [override] #
Write the provided content to the socket. This will stall until the socket responds in some manner. We assume the datagram has been connected.
Returns the number of bytes sent to the output, or Eof if the socket cannot write
size_t write(void[] src, Address to) #
Write an array to the specified address. If address 'to' is null, it is assumed the socket has been connected instead.
Returns the number of bytes sent to the output, or Eof if the socket cannot write