Artifact ae3bf436ecb3d8f75a418e0bd13bd41cb2f920d2eed1347c43d076d11bcc2e0a:

  • Executable file net/9/client.d — part of check-in [c922a978f8] at 2021-08-20 18:49:08 on branch trunk — add net/9, serial UDP server/client (user: admin size: 519)

#! /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]);
}