Boost logo

Boost :

From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2006-01-06 15:05:28

Pedro Lamarão wrote:
> Yuval Ronen wrote:
>>And one last suggestion: A construtor taking 4 unsigned chars, allowing
>>asio::ipv4::address my_address(192, 168, 0, 1);
> I suppose you meant four unsigned shorts?

As Chris noted, unsigned shorts would imply (to users, and to the
compiler) that the acceptable range is 16 bits and not 8 bits.

> What kind of use case do you have in mind for such a constructor?
> Where do you obtain IP address information as four distinct integers
> instead of a 32 bit integer as is standard?

Chris was right about this one, too. The main idea was parsing IP
addresses in a dot notation form. The Microsoft inet_addr() function I
used to use, reserved one IP address ( IIRC) to indicate
a parse error, and that wasn't acceptable in my case.

You might say that if asio's ip::address class provides dot notation
parsing, then I don't have to worry about it any more, and also don't
need this constructor, and you have a point there... but I also think
that this constructor just makes the code look nicer when I have the IP
address hard coded (which is not that often...)


Boost list run by bdawes at, gregod at, cpdaniel at, john at