File par/2-clockd/client.d from the latest check-in


import std.socket : TcpSocket, InternetAddress;
import std.stdio : stdout;
import std.exception : errnoEnforce;

void main() {
    auto client = new TcpSocket;
    scope (exit)
        client.close;
    client.connect(new InternetAddress("localhost", 8000));
    ubyte[4096] buffer;

    while (auto len = client.receive(buffer[])) {
        errnoEnforce(len > 0, "socket receive failed");
        stdout.write(cast(char[]) buffer[0 .. len]);
    }
}