Bind to a local address in order to receive packets sent there.
Initialize with the given AddressFamily, without binding to an address.
Called when a socket is writable.
Initialize with the given AddressFamily, without binding to an address.
Bind to a local address in order to receive packets sent there.
Where to send packets to.
t { auto server = new UdpConnection(); server.bind("127.0.0.1", 0); auto client = new UdpConnection(); client.initialize(server.localAddress.addressFamily); string[] packets = ["", "Hello", "there"]; client.remoteAddress = server.localAddress; client.send({ DataVec data; foreach (packet; packets) data ~= Data(packet.asBytes); return data; }()[]); server.handleReadData = (Data data) { assert(data.unsafeContents == packets[0]); packets = packets[1..$]; if (!packets.length) { server.close(); client.close(); } }; socketManager.loop(); assert(!packets.length
An asynchronous UDP stream. UDP does not have connections, so this class encapsulates a socket with a fixed destination (sendto) address, and optionally bound to a local address. Currently received packets' address is not exposed.