d strings are the bane of my existance

Chris Katko ckatko at gmail.com
Sun Dec 5 16:24:34 UTC 2021

All I want:

string ip_address = "";
auto x = new InternetAddress( ip_string, "8008");

source/app.d(161,16): Error: none of the overloads of `this` are 
callable using argument types `(string, int)`
/usr/include/dmd/phobos/std/socket.d(1472,5):        Candidates 
are: `std.socket.InternetAddress.this()`
    `std.socket.InternetAddress.this(scope const(char)[] addr, 
ushort port)`
    `std.socket.InternetAddress.this(uint addr, ushort port)`
    `std.socket.InternetAddress.this(ushort port)`
    `std.socket.InternetAddress.this(sockaddr_in addr)`

So InternetAddress cannot be constructed with a string. Only a 
const(char)[]. But toStringz gives me a immutable(char)*, which 
sounds like the same thing but isn't. and .dup on that just 
explodes. cast doesn't seem to work.  to! doesn't seem to work.

I know there "is" a solution, it's just so odd to have this much 
difficulty using a string.

More information about the Digitalmars-d-learn mailing list