Loading...
Searching...
No Matches
INETAddress.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// INETAddress.h
//------------------------------------------------------------------------------
// Copyright (c) 1999 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef INET_ADDRESS_H
#define INET_ADDRESS_H
#include <vector>
using std::vector;
#include "assa/Address.h"
namespace ASSA {
class INETAddress : public Address {
public:
enum Protocol {
TCP,
UDP
};
public:
INETAddress ();
INETAddress (struct in_addr * haddr_, int port_);
INETAddress(const char* host_, int port_);
INETAddress (const char* host_, const char* service_,
Protocol protocol_ = TCP);
INETAddress (int port_);
INETAddress (const char* address_, Protocol protocol_ = TCP);
INETAddress (SA_IN* address_);
INETAddress (SA* address_);
~INETAddress () {
// trace_with_mask("INETAddress::~INETAddress",SOCKTRACE);
}
const int getLength () const { return sizeof (m_address); }
SA* getAddress () const { return (SA*) &m_address; }
string getHostName ();
int getPort () const { return ntohs (m_address.sin_port); }
void dump ();
static string
get_fully_qualified_domain_name (vector<string>& aliases_);
private:
void createHostPort (const char* host_, int port_);
int getServiceByName (string serv_, Protocol prot_ = TCP);
void init ();
private:
static string m_fqdn_cache;
private:
SA_IN m_address;
};
} // end namespace ASSA
#endif /* INET_ADDRESS_H */
Address.h
Address is an abstraction for INET or UNIX-domain address data type.
ASSA::Address::Address
Address()
Constructor.
Definition Address.h:65
ASSA::INETAddress::init
void init()
Perform initialization common to all ctors.
Definition INETAddress.cpp:33
ASSA::INETAddress::getHostName
string getHostName()
Return host name.
Definition INETAddress.cpp:185
ASSA::INETAddress::dump
void dump()
Dump the address content to log file.
Definition INETAddress.cpp:206
ASSA::INETAddress::get_fully_qualified_domain_name
static string get_fully_qualified_domain_name(vector< string > &aliases_)
Return fully-qualified host name.
Definition INETAddress.cpp:231
ASSA::INETAddress::~INETAddress
~INETAddress()
Destructor.
Definition INETAddress.h:102
ASSA::INETAddress::getAddress
SA * getAddress() const
Get hold of address structure.
Definition INETAddress.h:110
ASSA::INETAddress::INETAddress
INETAddress()
Default constructor.
Definition INETAddress.cpp:39
ASSA::INETAddress::getServiceByName
int getServiceByName(string serv_, Protocol prot_=TCP)
Lookup port by its service name found in /etc/services.
Definition INETAddress.cpp:138
ASSA::INETAddress::getPort
int getPort() const
Return port.
Definition INETAddress.h:116
ASSA::INETAddress::createHostPort
void createHostPort(const char *host_, int port_)
Makes socket address out of host name and port.
Definition INETAddress.cpp:159
ASSA::INETAddress::Protocol
Protocol
Definition INETAddress.h:30
ASSA::INETAddress::UDP
@ UDP
UDP protocol.
Definition INETAddress.h:32
ASSA::INETAddress::TCP
@ TCP
TCP protocol.
Definition INETAddress.h:31
ASSA::INETAddress::m_address
SA_IN m_address
Internet address structure sockaddr_in.
Definition INETAddress.h:172
ASSA::INETAddress::m_fqdn_cache
static string m_fqdn_cache
Cached fully-qualified domain name.
Definition INETAddress.h:168
ASSA::INETAddress::getLength
const int getLength() const
Return address length.
Definition INETAddress.h:107
ASSA
Definition Acceptor.h:40
ASSA::SA_IN
struct sockaddr_in SA_IN
Definition Address.h:34
ASSA::SA
struct sockaddr SA
Definition Address.h:33