Module: Essential Networking Module Package: Networking
RWInetAddrRWSockAddrBase
addressType() as() asSockaddr() |
getHost() getPort() host() |
id() is() port() |
prepare() RWInetAddr() sockaddrSize() |
#include <rw/network/RWInetAddr.h>
Constructs a complete Internet address that includes type information, a host, and a port.
RWInetAddr addr(80, "www.roguewave.com");
RWInetAddr(); RWInetAddr(const RWInetPort& port); RWInetAddr(const RWInetPort& port, const RWInetHost& host, short type = SOCK_STREAM, short protocol = 0); RWInetAddr(const sockaddr_in& addr, short type = SOCK_STREAM, short protocol = 0);
Constructs an address for a TCP/IP Internet connection. The constructor that takes only a port argument creates a special address used to bind to any of the network interfaces on the machine on which the process is running. This is done, for example, when you are setting a server address. An address created using the default constructor binds to an arbitrary port number on any network interface on the local machine. These constructors do not block.
RWInetAddr(const RWCString& s);
Constructs an address from s, where s has the form type:host:port. Both type and host are optional. If type is supplied, it must be stream for a stream socket address or dgram for a datagram socket. The RWCString should contain 7-bit US-ASCII data.
virtual RWSockType addressType() const;
Returns the address type.
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 self is changed in any way or goes out of scope. If the address has no representation as a sockaddr, a null pointer is returned.
const RWInetHost getHost() const;
Returns the host part of the address.
const RWInetPort getPort() const;
Returns the port part of the address.
RWInetHost host() const;
Returns the host part of the address.
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.
RWInetPort port() const;
Returns the port part of the address.
virtual void prepare() const;
Ensures that future calls do not block on this address. If necessary, this function looks up the IP address and port number from the host name and service name. It is not necessary to call prepare(), but if you don't, future calls may block. No exceptions are thrown from prepare().
virtual size_t sockaddrSize() const;
Returns the size of an internal representation of the socket address defined by the sockets.
bool is(const RWSockAddrBase& addr);
Returns true if addr is an RWInetAddr.
RWInetAddr as(const RWSockAddrBase& addr);
Casts addr to RWInetAddr, if appropriate. Otherwise it throws an RWSockWrongAddressType exception.
bool operator==(const RWInetAddr& rhs) const;
Returns true if the two address objects are equal.
bool operator!=(const RWInetAddr& rhs) const;
Returns true if the two address objects are not equal.
ostream& operator>>(ostream& strm, const RWInetAddr& x);
Reads an address x from input stream strm.
© 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.