Artifact 04193814b2ac9fa07ecb5791d568ad2775969586f136a5b1a4e5211bd3059744:
- Executable file net/9/server.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: 559)
#! /usr/bin/env rdmd import std.socket : UdpSocket, InternetAddress, Address; import std.stdio : writefln; import std.algorithm : reverse; void main() { scope server = new UdpSocket; server.bind(new InternetAddress("localhost", 4444)); ubyte[128] buffer; Address client; ptrdiff_t len; while (true) { len = server.receiveFrom(buffer[], client); if (len <= 0) continue; writefln!"%s said: %s"(client, cast(char[]) buffer[0 .. len]); server.sendTo(buffer[0 .. len].reverse, client); } }