d strings are the bane of my existance

forkit forkit at gmail.com
Tue Dec 7 01:10:45 UTC 2021


On Sunday, 5 December 2021 at 16:24:34 UTC, Chris Katko wrote:
>
> I know there "is" a solution, it's just so odd to have this 
> much difficulty using a string.

Paying attention to the online docs would help you too ;-)

https://dlang.org/library/std/socket/internet_address.this.html

But, in the event you do 'need' to work with strings, you can 
just convert the string to ushort.


// ---
module test;

import std.stdio : writeln;
import std.socket : InternetAddress;
import std.conv : to;

void main()
{
     string host = "localhost";
     string port = "8080";

     auto ia = new InternetAddress(host, to!ushort(port));

     writeln(ia);
}

//-----------



More information about the Digitalmars-d-learn mailing list