nidas  v1.2-1520
SocketAddress.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2006, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 #ifndef NIDAS_UTIL_SOCKETADDRESS
27 #define NIDAS_UTIL_SOCKETADDRESS
28 
29 #include "Inet4Address.h"
30 
31 namespace nidas { namespace util {
32 
37 public:
38 
42  virtual SocketAddress* clone() const = 0;
43 
44  virtual ~SocketAddress() {}
45 
50  virtual int getFamily() const = 0;
51 
56  virtual int getPort() const = 0;
57 
64  virtual struct sockaddr* getSockAddrPtr() = 0;
65 
66  virtual const struct sockaddr* getConstSockAddrPtr() const = 0;
67 
72  virtual socklen_t getSockAddrLen() const = 0;
73 
77  virtual std::string toString() const = 0;
78 
82  virtual std::string toAddressString() const = 0;
83 
88  // virtual bool operator < (const SocketAddress& x) const = 0;
89 
93  // virtual bool operator == (const SocketAddress& x) const = 0;
94 
95 };
96 
97 }} // namespace nidas namespace util
98 
99 #endif
virtual struct sockaddr * getSockAddrPtr()=0
Provide non-const pointer to struct sockaddr_in.
An interface for a socket address.
Definition: SocketAddress.h:36
virtual socklen_t getSockAddrLen() const =0
Return the length of the struct sockaddr_XX for this address family.
virtual std::string toString() const =0
Java style toString.
virtual int getFamily() const =0
Get the family of this SocketAddress, one of the values from /usr/include/sys/socket.h: AF_UNIX, AF_INET, AF_INET6, etc.
virtual int getPort() const =0
return the port number of this address, or -1 if there is no associated port number, e.g.
virtual std::string toAddressString() const =0
Java style toString, but no DNS lookup.
virtual ~SocketAddress()
Definition: SocketAddress.h:44
virtual struct sockaddr * getConstSockAddrPtr() const =0
virtual SocketAddress * clone() const =0
Virtual constructor.