Looks much nicer than the current std.socket. A few random comments from a
quick scan of the code:
Socket.send/receive should use ubyte[], not void[] for the data.
I'd like some way to avoid new objects being created during any low-level
socket operation I expect to do regularly. For example, socket.receiveFrom
creates a new Address instance every time it's called. Perhaps I could have
the option to supply an Address object to be overwritten instead?
That Address.name() returns a sockaddr* is kind of weird. I'd expect it to
return a string? I know that the sockaddr is generally called a "name" in API
parlance, but it seems a bit weird in this context.
Why is InternetHost an instantiable object? It has data fields that aren't
initialized by any ctor, but only by calls where a hostent* is passed? And all
for access to API calls which no one is supposed to use anyway? Please just
make this go away :-)
There are a number of bool parameters that should really be EnumName.yes/no.
The current approach that appears to be required for connecting to a remote
host kind of stinks:
Socket sock = null;
foreach(info, getAddressInfo("www.digitalmars.com")) {
try {
sock = new Socket(info); // will throw if can't create a socket
based on info
sock.connect(info.address);
break;
} catch (Exception e) {
sock = null;
}
}
if (sock is null)
// unable to connect via any available method!
As an aside⦠From your comments, I gather that you're not terribly happy with
certain design requirements imposed by the existing std.socket. Why not create
an entirely new API in std.socket2 and not worry about it? Would your design
change enough to warrant doing this?