X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FBSDSocketAddress.hh;h=1e7d1e7737983cd81094594714a4de92d46ff578;hb=7baaacae27c02c86ceda5c7ee41d3172d1e23ffa;hp=61cb2204139bdccc839d61ad7f0ca4140007df72;hpb=56cc32ae48cac37909d4a3019c2e7b1729fc3ccd;p=senf.git diff --git a/Socket/Protocols/BSDSocketAddress.hh b/Socket/Protocols/BSDSocketAddress.hh index 61cb220..1e7d1e7 100644 --- a/Socket/Protocols/BSDSocketAddress.hh +++ b/Socket/Protocols/BSDSocketAddress.hh @@ -50,6 +50,20 @@ namespace senf { It is \e not possible to create or store BSDSocketAddress instances: You must either store an address in one of the specifically typed subclasses or using GenericBSDSocketAddress. + A BSDSocketAddress or GenericBSDSocketAddress can be cast (like a downcast) to (the correct) + type specific cast using sockaddr_cast: + + \code + void foo(senf::BSDSOcketAddress const & addr) + { + if (addr.family() == senf::INet4SocketAddress::addressFamily) { + senf::INet4SocketAddress i4addr ( + senf::sockaddr_cast(addr) ); + ... + } + } + \endcode + All these classes provide a generic \c sockaddr API to interface with legacy \c sockaddr based code (e.g. the BSD socket API). In this base-class, this interface is read-only, the derived classes however provide a read-write interface.