File net/9/client.d from the latest check-in


#! /usr/bin/env rdmd
import std.socket : UdpSocket, InternetAddress;
import std.stdio : writeln;
import std.range : retro;
import std.conv : to;

enum Greeting = "Hello, world!".retro.to!string;

void main() {
    auto client = new UdpSocket;
    client.connect(new InternetAddress("localhost", 4444));
    ubyte[128] buffer;
    client.send(Greeting);

    auto len = client.receive(buffer[]);
    assert(len >= 0, "client.receive failed. Probably the server's not up?");
    writeln(cast(char[]) buffer[0 .. len]);
}