Module: Essential Networking Module Package: Networking
RWSockAddrRWSockAddrBase
#include <rw/network/RWSockAddr.h>
RWSockAddr is a proxy to a socket address of a type that is not known until runtime. The RWSockAddr keeps a handle to a reference-counted RWSockAddrBase object, which is the real address. The RWSockAddr passes requests on to this object.
RWSockAddr();
Creates an invalid address. The address must be set to something useful before trying to use it. Common methods to set the address include shifting the address in from an std::istream or using the assignment operator.
RWSockAddr(sockaddr *addr, int len); RWSockAddr(sockaddr *addr, int len, int type);
Creates an address object from the C API representation. This constructor uses the rwSockAddrFactory to look up a specific construction routine to construct the address. An RWNetNoNumberFactoryRegisteredError exception is thrown if the address is not a recognized type.
RWSockAddr(const RWCString& str);
Constructs an address from the address specification in the string. The first token in the string indicates the type of address. The remainder indicates the specific address. Examples of the format are "inet ftp.roguewave.com ftp" and "inet www.roguewave.com 80." The RWSockAddrFactory is used to actually construct the address. An RWNetNoNameFactoryRegisteredError exception is thrown if the address is not a recognized type. The RWCString should contain 7-bit US-ASCII data.
RWSockAddr(RWSockAddrBase* addr);
Constructs an RWSockAddr that represents addr. addr must be an object allocated on the heap. It is deleted when no RWSockAddr objects refer to it. This constructor is available for general use, but it is most often used by the RWSockAddrFactory.
virtual RWSockType addressType() const;
Returns the type of address.
virtual sockaddr* asSockaddr() const;
Returns a pointer to an internal representation of the address that was cast to a sockaddr structure, as defined by the sockets and TLI APIs (TLI is the Unix System V network communication interface). The pointer is to an internal data structure, so it becomes invalid if this object is changed in any way or goes out of scope. If the address has no representation as a sockaddr, a null pointer is returned.
RWCString id(unsigned level=0) const;
Returns a string describing self. The verbosity of the output is controlled by level where level=0 is the most basic output, and level=9 is the most verbose. The RWCString should contain 7-bit US-ASCII data.
bool isValid() const;
Returns true if this address is a proxy to a real address. A proxy to an invalid address is created using the default constructor.
virtual void prepare() const;
Forwards the prepare() request onto the real address object. The address object sets up all internal data so that subsequent calls to interfaces on this address do not block.
virtual size_t sockaddrSize() const;
Returns the size of an internal representation of the socket address defined by the sockets.
istream operator>>(istream&, RWSockAddr&); ostream operator<<(ostream&, RWSockAddr&);
Reads an address from an input stream or writes it onto an output stream.
Addr as<Addr>(const RWSockAddr& addr);
Returns addr typed as an Addr. If addr is not of type Addr, an exception is thrown. For compilers that do not support explicit template functions, you can use Addr::as(const RWSockAddr& addr) for each derived type Addr.
bool is<Addr>(const RWSockAddr& addr);
Returns true if addr is of type Addr. For compilers that do not support explicit template functions, you can use Addr::is(const RWSockAddr& addr) for each derived type Addr.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.