[phobos] Breaking changes for std.socket improvement

Sean Kelly sean at invisibleduck.org
Tue Jul 6 20:24:04 PDT 2010


Sounds great.

Sent from my iPhone

On Jul 5, 2010, at 12:08 PM, "Masahiro Nakagawa" <repeatedly at gmail.com> wrote:

> std.socket lacks some features and I don't like current design. So, I rewrote this module.
> 
> Summary:
> 
> - Change API of Protocol, Service, and InternetHost.
> 
> -----
> /* old */
> Protocol proto = new Protocol;  // construct before check
> enforce(proto.getProtocolByType(ProtocolType.TCP));  // check
> // do stuff
> 
> /* new */
> Protocol proto = enforce(Protocol.getByType(ProtocolType.TCP));  // construct after check
> // do stuff
> -----
> 
> I leaves these classes for aliases(getaddrinfo can't get aliases).
> 
> - Add AddressInfo class(wraps C's addrinfo struct)
> 
> AddressInfo resolves some address familes. I added AF_UNIX support.
> This class is useful for Socket and Endpoint initialization.
> 
> In the future, above classes should be moved to std.net(or std.net.dns).
> 
> - Endpoint
> 
> I think Address should not have port. Address is a address, not a endpoint.
> So I added Endpoint structs(derived their name from Asio) and Endpoints use corresponding Addresses.
> 
> -- IPEndpoint
> 
> This struct supports IPv4 and IPv6 using IPAddress.
> 
> -- LocalEndpoint
> 
> This struct supports local path using LocalAddress.
> 
> - Socket
> 
> Socket is a template bacause Socket should support any address familes.
> Old Socket uses class-inheritance, but newFamilyObject is bad(newFamilyObject can't use user-defined class).
> 
> Some methods of old Socket used return-value checking :(
> 
> - SocketSet
> 
> add and remove methods are typesafe-variadic function.
> 
> - Add const and attribute
> 
> Sources:
> 
> - socket.d
> http://bitbucket.org/repeatedly/scrap/src/tip/socket.d
> 
> unittest is a simple example.
> 
> - socketstream.d
> http://bitbucket.org/repeatedly/scrap/src/tip/socketstream.d
> 
> std.stream will be replaced or eliminated. This module need?
> 
> - LocalEndpoint sample
> http://bitbucket.org/repeatedly/scrap/src/tip/sample/echo_server.d
> http://bitbucket.org/repeatedly/scrap/src/tip/sample/echo_client.d
> 
> Contribution from satoru_h
> 
> 
> I would like to commit this change. What do you think?
> 
> 
> Masahiro
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list