Logo
~Sockets~
~Examples~
~Contact~


Ipv4Address.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2007  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #ifndef _SOCKETS_Ipv4Address_H
00024 #define _SOCKETS_Ipv4Address_H
00025 
00026 #include "sockets-config.h"
00027 #include "SocketAddress.h"
00028 
00029 
00030 #ifdef SOCKETS_NAMESPACE
00031 namespace SOCKETS_NAMESPACE {
00032 #endif
00033 
00034 
00035 /* Ipv4 address implementation.
00036         \ingroup basic */
00037 class Ipv4Address : public SocketAddress
00038 {
00039 public:
00042         Ipv4Address(port_t port = 0);
00046         Ipv4Address(ipaddr_t a,port_t port);
00050         Ipv4Address(struct in_addr& a,port_t port);
00054         Ipv4Address(const std::string& host,port_t port);
00055         Ipv4Address(struct sockaddr_in&);
00056         ~Ipv4Address();
00057 
00058         // SocketAddress implementation
00059 
00060         operator struct sockaddr *();
00061         operator socklen_t();
00062         bool operator==(SocketAddress&);
00063 
00064         void SetPort(port_t port);
00065         port_t GetPort();
00066 
00067         void SetAddress(struct sockaddr *sa);
00068         int GetFamily();
00069 
00070         bool IsValid();
00071         std::auto_ptr<SocketAddress> GetCopy();
00072 
00074         std::string Convert(bool include_port = false);
00075         std::string Reverse();
00076 
00078 static  bool Resolve(const std::string& hostname,struct in_addr& a);
00080 static  bool Reverse(struct in_addr& a,std::string& name);
00082 static  std::string Convert(struct in_addr& a);
00083 
00084 private:
00085         Ipv4Address(const Ipv4Address& ) {} // copy constructor
00086         Ipv4Address& operator=(const Ipv4Address& ) { return *this; } // assignment operator
00087         struct sockaddr_in m_addr;
00088         bool m_valid;
00089 };
00090 
00091 
00092 
00093 
00094 #ifdef SOCKETS_NAMESPACE
00095 } // namespace SOCKETS_NAMESPACE {
00096 #endif
00097 #endif // _SOCKETS_Ipv4Address_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4