Artifact 7c885f26d01553331fafe3c914fb5be3bf677e93d12a5f667d689439d2407bb4:
- File par/2-clockd/client.d — part of check-in [5b30d6891f] at 2021-10-30 19:55:14 on branch trunk — add Concurrent Clock Server example from Go Programming Language (user: admin size: 451)
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]); } }