2001-10-06 14:13:28 +00:00
|
|
|
#ifndef CNETWORKADDRESS_H
|
|
|
|
#define CNETWORKADDRESS_H
|
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
#include "CNetwork.h"
|
2002-06-09 16:53:25 +00:00
|
|
|
#include "CString.h"
|
|
|
|
#include "BasicTypes.h"
|
2001-10-06 14:13:28 +00:00
|
|
|
|
|
|
|
class CNetworkAddress {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2002-06-09 16:53:25 +00:00
|
|
|
// invalid address
|
|
|
|
CNetworkAddress();
|
|
|
|
|
|
|
|
// wildcard address and given port. port must not be zero.
|
2001-10-14 16:58:01 +00:00
|
|
|
CNetworkAddress(UInt16 port);
|
2002-06-09 16:53:25 +00:00
|
|
|
|
|
|
|
// given address and port. if hostname can be parsed as numerical
|
|
|
|
// address then that's how it's used, otherwise the hostname is
|
|
|
|
// looked up. if lookup fails then it throws XSocketAddress. if
|
|
|
|
// hostname ends in ":[0-9]+" then that suffix is extracted and
|
|
|
|
// used as the port, overridding the port parameter. neither
|
|
|
|
// port may be zero.
|
2001-10-14 16:58:01 +00:00
|
|
|
CNetworkAddress(const CString& hostname, UInt16 port);
|
2002-06-09 16:53:25 +00:00
|
|
|
|
2001-10-06 14:13:28 +00:00
|
|
|
~CNetworkAddress();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
2002-06-09 16:53:25 +00:00
|
|
|
// returns true if this is not the invalid address
|
|
|
|
bool isValid() const;
|
|
|
|
|
|
|
|
// get the address
|
2001-11-19 00:33:36 +00:00
|
|
|
const CNetwork::Address* getAddress() const;
|
|
|
|
CNetwork::AddressLength getAddressLength() const;
|
2001-10-06 14:13:28 +00:00
|
|
|
|
2002-06-09 16:53:25 +00:00
|
|
|
// get the hostname and port (as provided in the c'tor)
|
|
|
|
CString getHostname() const;
|
|
|
|
UInt16 getPort() const;
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2001-11-19 00:33:36 +00:00
|
|
|
CNetwork::Address m_address;
|
2002-06-09 16:53:25 +00:00
|
|
|
CString m_hostname;
|
|
|
|
UInt16 m_port;
|
2001-10-06 14:13:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|