On Wed, Sep 30, 2020 at 2:40 PM seany via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:
> On Wednesday, 30 September 2020 at 12:29:06 UTC, Daniel Kozak > wrote: > > to separate the messages from the IoT responses quickly and > forward them to different programs, and to have the capability in > hand, so that when later i have an idea to exploit the > capability, I can also do it. > Ok as Adam said you can do something like this: void main() { immutable ushort startPort = 5500; import std.range : iota; foreach (ushort port; iota!(ushort,ushort)(startPort, startPort + 100)) { auto settings = new HTTPServerSettings; settings.port = port; settings.bindAddresses = ["::1", "127.0.0.1"]; listenHTTP(settings, &hello); } runApplication(); } void hello(HTTPServerRequest req, HTTPServerResponse res) { import std.conv : to; res.writeBody(req.fullURL.port.to!string); }