psocksxx  1.0.0
nsockaddr.h
1 /*
2 * psocksxx - A C++ wrapper for POSIX sockets
3 * Copyright (C) 2013 Uditha Atukorala
4 *
5 * This software library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This software library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this software library. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19 
20 #ifndef PSOCKSXX_NSOCKADDR_H
21 #define PSOCKSXX_NSOCKADDR_H
22 
23 #include <psocksxx/sockaddr.h>
24 #include <psocksxx/sockexception.h>
25 #include <netinet/in.h>
26 
27 
28 namespace psocksxx {
29 
37  class nsockaddr : public sockaddr, public sockaddr_in {
38  public:
39 
50  nsockaddr( const char * node, unsigned short port ) throw( sockexception );
51 
61  nsockaddr( unsigned short port ) throw();
62 
73  nsockaddr( const char * node, const char * service ) throw( sockexception );
74 
75  // abstract method implementations
76  socklen_t size() const throw();
77  ::sockaddr* psockaddr() const throw();
78 
79 
80  protected:
81 
92  in_addr_t resolve_node( const char * node ) throw( sockexception );
93 
94  };
95 
96 } /* end of namespace psockxx */
97 
98 #endif /* !PSOCKSXX_NSOCKADDR_H */
99 
Socket exception.
Definition: sockexception.h:35
socklen_t size() const
get POSIX socket address size
Definition: nsockaddr.cpp:127
nsockaddr(const char *node, unsigned short port)
constructor
Definition: nsockaddr.cpp:29
Definition: iosocks.cpp:23
::sockaddr * psockaddr() const
get a POSIX socket address structure
Definition: nsockaddr.cpp:132
Socket address class for IPv4 addresses.
Definition: nsockaddr.h:37
Socket address base class.
Definition: sockaddr.h:35
in_addr_t resolve_node(const char *node)
convert a node name to a IPv4 address
Definition: nsockaddr.cpp:97