libassa 3.5.1
Loading...
Searching...
No Matches
INETAddress.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// INETAddress.h
4//------------------------------------------------------------------------------
5// Copyright (c) 1999 by Vladislav Grinchenko
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//------------------------------------------------------------------------------
12#ifndef INET_ADDRESS_H
13#define INET_ADDRESS_H
14
15#include <vector>
16using std::vector;
17
18#include "assa/Address.h"
19
20namespace ASSA {
21
27class INETAddress : public Address {
28public:
30 enum Protocol {
32 UDP
33 };
34
35public:
37 INETAddress ();
38
45 INETAddress (struct in_addr * haddr_, int port_);
46
53 INETAddress(const char* host_, int port_);
54
63 INETAddress (const char* host_, const char* service_,
65
71 INETAddress (int port_);
72
93 INETAddress (const char* address_, Protocol protocol_ = TCP);
94
97
100
103// trace_with_mask("INETAddress::~INETAddress",SOCKTRACE);
104 }
105
107 const int getLength () const { return sizeof (m_address); }
108
110 SA* getAddress () const { return (SA*) &m_address; }
111
113 string getHostName ();
114
116 int getPort () const { return ntohs (m_address.sin_port); }
117
119 void dump ();
120
128 static string
130
131private:
148 void createHostPort (const char* host_, int port_);
149
160 int getServiceByName (string serv_, Protocol prot_ = TCP);
161
164 void init ();
165
166private:
168 static string m_fqdn_cache;
169
170private:
173};
174
175
176} // end namespace ASSA
177
178#endif /* INET_ADDRESS_H */
Address is an abstraction for INET or UNIX-domain address data type.
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
void init()
Perform initialization common to all ctors.
string getHostName()
Return host name.
void dump()
Dump the address content to log file.
static string get_fully_qualified_domain_name(vector< string > &aliases_)
Return fully-qualified host name.
~INETAddress()
Destructor.
SA * getAddress() const
Get hold of address structure.
INETAddress()
Default constructor.
int getServiceByName(string serv_, Protocol prot_=TCP)
Lookup port by its service name found in /etc/services.
int getPort() const
Return port.
void createHostPort(const char *host_, int port_)
Makes socket address out of host name and port.
@ UDP
UDP protocol.
Definition INETAddress.h:32
@ TCP
TCP protocol.
Definition INETAddress.h:31
SA_IN m_address
Internet address structure sockaddr_in.
static string m_fqdn_cache
Cached fully-qualified domain name.
const int getLength() const
Return address length.
struct sockaddr_in SA_IN
Definition Address.h:34
struct sockaddr SA
Definition Address.h:33